From 440489af6737085ad0a630a35262653f1f990239 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Wed, 12 May 2021 01:05:39 -0400 Subject: [PATCH] purge memory if munmap fails --- pages.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pages.c b/pages.c index cd4684c..505c884 100644 --- a/pages.c +++ b/pages.c @@ -86,5 +86,7 @@ void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_ } void deallocate_pages(void *usable, size_t usable_size, size_t guard_size) { - memory_unmap((char *)usable - guard_size, usable_size + guard_size * 2); + if (unlikely(memory_unmap((char *)usable - guard_size, usable_size + guard_size * 2))) { + memory_purge(usable, usable_size); + } }