From 64e9f6797ad8c38c1c44c15a1e75135296a1e966 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 16 Oct 2018 15:52:41 -0400 Subject: [PATCH] use offsetof for allocator_state memory protection --- malloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/malloc.c b/malloc.c index 5ba8b8b..2629e8c 100644 --- a/malloc.c +++ b/malloc.c @@ -777,8 +777,7 @@ COLD static void init_slow_path(void) { if (allocator_state == NULL) { fatal_error("failed to reserve allocator state"); } - if (memory_protect_rw(allocator_state, sizeof(allocator_state->size_class_metadata) + - sizeof(allocator_state->region_allocator))) { + if (memory_protect_rw(allocator_state, offsetof(struct allocator_state, regions_a))) { fatal_error("failed to unprotect allocator state"); }