mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
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.
This commit is contained in:
parent
b77d343bc8
commit
a5d78cc208
3 changed files with 24 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue