gh-121460: Skip freeing unallocated arenas (gh-121491)

`munmap(NULL)` is not noop, like `free(NULL)` is.

Fixes an observed testsuite hang on 32-bit ARM systems.
This commit is contained in:
Stefano Rivera 2024-07-10 09:40:55 -07:00 committed by GitHub
parent 0177a34335
commit a802277914
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -386,8 +386,16 @@ _PyMem_ArenaFree(void *Py_UNUSED(ctx), void *ptr,
)
{
#ifdef MS_WINDOWS
/* Unlike free(), VirtualFree() does not special-case NULL to noop. */
if (ptr == NULL) {
return;
}
VirtualFree(ptr, 0, MEM_RELEASE);
#elif defined(ARENAS_USE_MMAP)
/* Unlike free(), munmap() does not special-case NULL to noop. */
if (ptr == NULL) {
return;
}
munmap(ptr, size);
#else
free(ptr);