From 4a5b3a33b980266a7b64d9d08023c1bd4c87a7ad Mon Sep 17 00:00:00 2001 From: Thibaut Sautereau Date: Wed, 10 Feb 2021 09:18:26 +0100 Subject: [PATCH] Check return value of memory_map_fixed() All other calls to memory_map_fixed() are checked, and this one may also theoretically fail. --- h_malloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/h_malloc.c b/h_malloc.c index 625ca5f..516c5e9 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -903,7 +903,10 @@ static int regions_grow(void) { } } - memory_map_fixed(ra->regions, ra->total * sizeof(struct region_metadata)); + if (memory_map_fixed(ra->regions, ra->total * sizeof(struct region_metadata))) { + return 1; + } + memory_set_name(ra->regions, ra->total * sizeof(struct region_metadata), "malloc allocator_state"); ra->free = ra->free + ra->total; ra->total = newtotal;