]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - zone.c
Don't crash the game if a "nasty" -game name is rejected, matches behavior of missing...
[xonotic/darkplaces.git] / zone.c
diff --git a/zone.c b/zone.c
index 5a0c8987a0c3e2f184999aa0ed09e2ff46dc72bc..e2ec8ca75d5560a62d018c563f3aa8945a8bab7f 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -107,6 +107,9 @@ void Mem_PrintList(size_t minallocationsize);
 #if FILE_BACKED_MALLOC
 #include <stdlib.h>
 #include <sys/mman.h>
+#ifndef MAP_NORESERVE
+#define MAP_NORESERVE 0
+#endif
 typedef struct mmap_data_s
 {
        size_t len;
@@ -127,7 +130,7 @@ static void *mmap_malloc(size_t size)
        data = (unsigned char *) mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERVE, fd, 0);
        close(fd);
        unlink(vabuf);
-       if(!data)
+       if(!data || data == (void *)-1)
                return NULL;
        data->len = size;
        return (void *) (data + 1);
@@ -758,9 +761,9 @@ void Mem_ExpandableArray_FreeRecord(memexpandablearray_t *l, void *record) // co
                {
                        j = (p - l->arrays[i].data) / l->recordsize;
                        if (p != l->arrays[i].data + j * l->recordsize)
-                               Sys_Error("Mem_ExpandableArray_FreeRecord: no such record %p\n", p);
+                               Sys_Error("Mem_ExpandableArray_FreeRecord: no such record %p\n", (void *)p);
                        if (!l->arrays[i].allocflags[j])
-                               Sys_Error("Mem_ExpandableArray_FreeRecord: record %p is already free!\n", p);
+                               Sys_Error("Mem_ExpandableArray_FreeRecord: record %p is already free!\n", (void *)p);
                        l->arrays[i].allocflags[j] = false;
                        l->arrays[i].numflaggedrecords--;
                        return;