rts/M32Alloc: Abort if m32 linker mmap fails
authorBen Gamari <ben@smart-cactus.org>
Sat, 10 Nov 2018 20:35:37 +0000 (15:35 -0500)
committerBen Gamari <ben@smart-cactus.org>
Thu, 22 Nov 2018 17:11:16 +0000 (12:11 -0500)
Previously we should just blinding dereference a NULL pointer.

rts/linker/M32Alloc.c

index 6a2996d..52b182e 100644 (file)
@@ -158,6 +158,9 @@ m32_allocator_init(void)
    // fragment the memory.
    size_t pgsz = getPageSize();
    char* bigchunk = mmapForLinker(pgsz * M32_MAX_PAGES,MAP_ANONYMOUS,-1,0);
+   if (bigchunk == NULL)
+       barf("m32_allocator_init: Failed to map");
+
    int i;
    for (i=0; i<M32_MAX_PAGES; i++) {
       alloc.pages[i].base_addr = bigchunk + i*pgsz;