diff options
author | Stefano Rivera <stefano@rivera.za.net> | 2024-07-10 16:40:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 16:40:55 (GMT) |
commit | a802277914405786f6425f2776605c44bd407fc0 (patch) | |
tree | f089f908c1f00c43e9bc246eb1dc68683ec2d3ef /Objects | |
parent | 0177a343353d88ca8475dccabf6e98e164abb0e8 (diff) | |
download | cpython-a802277914405786f6425f2776605c44bd407fc0.zip cpython-a802277914405786f6425f2776605c44bd407fc0.tar.gz cpython-a802277914405786f6425f2776605c44bd407fc0.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/obmalloc.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index d033e2b..a6a7180 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -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); |