From 2a615bc3c553db117097b11393b32bfc33169fcb Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 3 Feb 2025 01:23:41 +0100 Subject: [PATCH] xml_lpm_fuzzer: Unstuck MallocHook and ReallocHook .. so that they fail single allocations, not all allocations after a certain point. Previously fail_allocations of [6, 2, 20] worked the same way fail_allocations of [2], likely by accidently. --- expat/fuzz/xml_lpm_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/expat/fuzz/xml_lpm_fuzzer.cpp b/expat/fuzz/xml_lpm_fuzzer.cpp index a2982fc2..87c99be1 100644 --- a/expat/fuzz/xml_lpm_fuzzer.cpp +++ b/expat/fuzz/xml_lpm_fuzzer.cpp @@ -79,23 +79,23 @@ static std::vector g_fail_allocations = {}; void * MallocHook(size_t size) { + g_allocation_count += 1; for (auto index : g_fail_allocations) { if (index == g_allocation_count) { return NULL; } } - g_allocation_count += 1; return malloc(size); } void * ReallocHook(void *ptr, size_t size) { + g_allocation_count += 1; for (auto index : g_fail_allocations) { if (index == g_allocation_count) { return NULL; } } - g_allocation_count += 1; return realloc(ptr, size); }