Skip to content

Commit 57db7cc

Browse files
committed
preserve zeroing on madvise out-of-memory error
1 parent 0f0b758 commit 57db7cc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pages.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <errno.h>
2+
#include <string.h>
23

34
#include "memory.h"
45
#include "pages.h"
@@ -83,6 +84,8 @@ void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_
8384

8485
void deallocate_pages(void *usable, size_t usable_size, size_t guard_size) {
8586
if (unlikely(memory_unmap((char *)usable - guard_size, usable_size + guard_size * 2))) {
86-
memory_purge(usable, usable_size);
87+
if (unlikely(memory_purge(usable, usable_size))) {
88+
memset(usable, 0, usable_size);
89+
}
8790
}
8891
}

0 commit comments

Comments
 (0)