Index: src/platform-macos.cc |
diff --git a/src/platform-macos.cc b/src/platform-macos.cc |
index 3e4daf3bbb320e391938ddd0cd913ccae8b5f0a5..5e0e78dbf8f141baaa6777d2112f5123f8b3e8a5 100644 |
--- a/src/platform-macos.cc |
+++ b/src/platform-macos.cc |
@@ -206,7 +206,11 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size, |
void* initial) { |
FILE* file = fopen(name, "w+"); |
if (file == NULL) return NULL; |
- fwrite(initial, size, 1, file); |
+ int result = fwrite(initial, size, 1, file); |
+ if (result < 1) { |
+ fclose(file); |
+ return NULL; |
+ } |
void* memory = |
mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0); |
return new PosixMemoryMappedFile(file, memory, size); |