`munmap(NULL)` is not noop, like `free(NULL)` is.
Fixes an observed testsuite hang on 32-bit ARM systems.
(cherry picked from commit
a802277914405786f6425f2776605c44bd407fc0, AKA gh-121491)
Co-authored-by: Stefano Rivera <stefano@rivera.za.net>
)
{
#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);