diff options
author | Michael W. Hudson <mwh@python.net> | 2002-03-05 14:23:56 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2002-03-05 14:23:56 (GMT) |
commit | fc7af7705ca0b381a9abd0535d02bd44e3f07ced (patch) | |
tree | 53898b0f60d42c6149d3a8f7c2b3c5171c42cc35 | |
parent | dd6186d4f624075a9036d843e00d9fb1134a8a2c (diff) | |
download | cpython-fc7af7705ca0b381a9abd0535d02bd44e3f07ced.zip cpython-fc7af7705ca0b381a9abd0535d02bd44e3f07ced.tar.gz cpython-fc7af7705ca0b381a9abd0535d02bd44e3f07ced.tar.bz2 |
backport tim_one's checkin of
revision 2.164 of object.c
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.
-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 5812178..0541fbd 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1888,11 +1888,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 |