From e57bf03885fdc1caf8241b5fb934354deb9ffe98 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Sun, 26 Jan 2020 15:20:37 +0100 Subject: Guard against smarter compiler. --- vespamalloc/src/tests/overwrite/overwrite.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'vespamalloc') diff --git a/vespamalloc/src/tests/overwrite/overwrite.cpp b/vespamalloc/src/tests/overwrite/overwrite.cpp index b016c13ab61..84f96fbbb3e 100644 --- a/vespamalloc/src/tests/overwrite/overwrite.cpp +++ b/vespamalloc/src/tests/overwrite/overwrite.cpp @@ -10,6 +10,13 @@ void check_ptr_real(void *ptr) void (*check_ptr)(void *ptr) = check_ptr_real; +void overwrite_memory_real(char *ptr, int offset) +{ + *(ptr + offset) = 0; +} + +void (*overwrite_memory)(char *ptr, int offset) = overwrite_memory_real; + class Test : public TestApp { public: @@ -63,16 +70,14 @@ void Test::testFillValue(char *a) void Test::verifyPreWriteDetection() { char * a = new char[8]; - *(a-1) = 0; - check_ptr(a); + overwrite_memory(a, -1); delete [] a; } void Test::verifyPostWriteDetection() { char * a = new char[8]; - a[8] = 0; - check_ptr(a); + overwrite_memory(a, 8); delete [] a; } -- cgit v1.2.3