From 3572544b813d8bcc4032cb2028905468e45ca9a9 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 26 Dec 2021 23:06:28 +0100 Subject: [PATCH] Simplify a bit write_after_free_check No need to have a variable check when the preprocessor can do the job. --- h_malloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/h_malloc.c b/h_malloc.c index 7736177..dac79de 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -439,15 +439,13 @@ static void *slot_pointer(size_t size, void *slab, size_t slot) { } static void write_after_free_check(const char *p, size_t size) { - if (!WRITE_AFTER_FREE_CHECK) { - return; - } - +#ifdef WRITE_AFTER_FREE_CHECK for (size_t i = 0; i < size; i += sizeof(u64)) { if (*(const u64 *)(const void *)(p + i)) { fatal_error("detected write after free"); } } +#endif } static const u64 canary_mask = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ?