diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-03-02 08:43:19 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-03-02 08:43:19 (GMT) |
commit | a5d78cc208c24be62b50b6d1540e03be6612d3f2 (patch) | |
tree | eda122d61fdabb1c1579ab4d8ff0898872a15f7c /Objects/object.c | |
parent | b77d343bc846c2049a4cffb1dfd65eb49d1728b4 (diff) | |
download | cpython-a5d78cc208c24be62b50b6d1540e03be6612d3f2.zip cpython-a5d78cc208c24be62b50b6d1540e03be6612d3f2.tar.gz cpython-a5d78cc208c24be62b50b6d1540e03be6612d3f2.tar.bz2 |
Whether platform malloc(0) returns NULL has nothing to do with whether
platform realloc(p, 0) returns NULL, so MALLOC_ZERO_RETURNS_NULL can
be correctly undefined yet realloc(p, 0) can return NULL anyway.
Prevent realloc(p, 0) doing free(p) and returning NULL via a different
hack. Would probably be better to get rid of MALLOC_ZERO_RETURNS_NULL
entirely.
Bugfix candidate.
Diffstat (limited to 'Objects/object.c')
-rw-r--r-- | Objects/object.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/Objects/object.c b/Objects/object.c index 8babf79..bcc129c 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1894,11 +1894,8 @@ PyMem_Malloc(size_t nbytes) void * PyMem_Realloc(void *p, size_t nbytes) { -#if _PyMem_EXTRA > 0 - if (nbytes == 0) - nbytes = _PyMem_EXTRA; -#endif - return PyMem_REALLOC(p, nbytes); + /* See comment near MALLOC_ZERO_RETURNS_NULL in pyport.h. */ + return PyMem_REALLOC(p, nbytes ? nbytes : 1); } void |