By sheer coincidence I ran into this myself the other day. God knows
how long it has been there waiting until I tried those old demos
again!
The cause is simple: the empty list [] is being copied to a malloc'ed
array of floats which causes a call to malloc(0). This returns NULL on
some systems, and of course the check for malloc errors takes that as
an error return. This can happen in other situations too.
As a temporary measure (though this is a waste of some memory), I
added 1 to the malloc and realloc arguments in the definitions of NEW
and RENEW in [my]malloc.h (the file's name changed at I don't know
which release):
/* XXX Always allocate one extra byte, since some malloc's return NULL
XXX for malloc(0) or realloc(p, 0). */
#define NEW(type, n) ( (type *) malloc(1 + (n) * sizeof(type)) )
#define RESIZE(p, type, n) \
if ((p) == NULL) \
(p) = (type *) malloc(1 + (n) * sizeof(type)); \
else \
(p) = (type *) realloc((ANY *)(p), 1 + (n) * sizeof(type))
Eventually I'll probably use a less wasteful fix (Python is a really
heavy malloc user and every byte counts!).
I wonder -- will I really have to use a configure script like the GNU
software uses? I'd much rather write portable code that doesn't need
to be configured, but I hate it if it gets wasteful that way...
--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"The man from the cat-detector van."