Browse Source

Fixed a crash on some systems when freeing memory

SChernykh 1 year ago
parent
commit
afc64ebaa7
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/virtual_memory.c

+ 4 - 1
src/virtual_memory.c

@@ -235,6 +235,9 @@ void freePagedMemory(void* ptr, size_t bytes) {
 #if defined(_WIN32) || defined(__CYGWIN__)
 	VirtualFree(ptr, 0, MEM_RELEASE);
 #else
-	munmap(ptr, bytes);
+	// some munmap implementations can crash on null pointer, despite what the manpage says
+	if (ptr) {
+		munmap(ptr, bytes);
+	}
 #endif
 }