From c37b591d33de5c898d68e0a1088182e368c366fd Mon Sep 17 00:00:00 2001 From: Max Wash Date: Tue, 24 May 2022 21:34:06 +0100 Subject: [PATCH] Heap initialisation failure now results in abort() being called --- photon/libc/sys/horizon/heap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/photon/libc/sys/horizon/heap.c b/photon/libc/sys/horizon/heap.c index de9c736..33a3fd4 100644 --- a/photon/libc/sys/horizon/heap.c +++ b/photon/libc/sys/horizon/heap.c @@ -29,16 +29,25 @@ void __crt_heap_init(size_t sz) mx_status_t status = mx_vmar_allocate(root_vmar, MX_VM_CAN_MAP_READ | MX_VM_CAN_MAP_WRITE | MX_VM_CAN_MAP_SPECIFIC, 0, HEAP_REGION_SZ, &heap_vmar, &heap); + if (status != MX_OK) { + abort(); + } status = mx_vmo_create( sz, MX_VM_CAN_MAP_READ | MX_VM_CAN_MAP_WRITE | MX_VM_CAN_MAP_SPECIFIC, &heap_vmo); + if (status != MX_OK) { + abort(); + } - mx_vmar_map(heap_vmar, + status = mx_vmar_map(heap_vmar, MX_VM_PERM_READ | MX_VM_PERM_WRITE | MX_VM_SPECIFIC, 0, heap_vmo, 0, sz, &heap); + if (status != MX_OK) { + abort(); + } heap_sz = sz; heap_start = heap;