Explorar o código

Merge pull request #310 from SChernykh/fix-munmap

Fixed a crash on some systems when freeing memory
SChernykh hai 1 ano
pai
achega
cb29ec5690
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  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
 }