From a13a45a17da2d540fe3f7d96c4e639f53ce4fc53 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 26 Aug 2018 04:37:43 -0400 Subject: [PATCH] hold regions_lock in alloc_aligned --- malloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/malloc.c b/malloc.c index 71f77a1..6f2f66d 100644 --- a/malloc.c +++ b/malloc.c @@ -790,10 +790,15 @@ static int alloc_aligned(void **memptr, size_t alignment, size_t size, size_t mi if (p == NULL) { return ENOMEM; } + + pthread_mutex_lock(®ions_lock); if (regions_insert(p, size)) { + pthread_mutex_unlock(®ions_lock); deallocate_pages(p, size, PAGE_SIZE); return ENOMEM; } + pthread_mutex_unlock(®ions_lock); + *memptr = p; return 0; }