Mercurial > cpython-lru_cache-weakref
diff Objects/object.c @ 22112:8b104a85b99c legacy-trunk
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.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Sat, 02 Mar 2002 08:43:19 +0000 |
| parents | 93eb4b61f687 |
| children | a0cc52735e6e |
line wrap: on
line diff
--- a/Objects/object.c Sat Mar 02 07:16:21 2002 +0000 +++ b/Objects/object.c Sat Mar 02 08:43:19 2002 +0000 @@ -1894,11 +1894,8 @@ 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
