Skip to content

Commit cb29ec5

Browse files
authored
Merge pull request #310 from SChernykh/fix-munmap
Fixed a crash on some systems when freeing memory
2 parents 7bf186b + afc64eb commit cb29ec5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/virtual_memory.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ void freePagedMemory(void* ptr, size_t bytes) {
235235
#if defined(_WIN32) || defined(__CYGWIN__)
236236
VirtualFree(ptr, 0, MEM_RELEASE);
237237
#else
238-
munmap(ptr, bytes);
238+
// some munmap implementations can crash on null pointer, despite what the manpage says
239+
if (ptr) {
240+
munmap(ptr, bytes);
241+
}
239242
#endif
240243
}

0 commit comments

Comments
 (0)