diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2020-01-26 15:20:37 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2020-01-26 15:28:30 +0100 |
commit | e57bf03885fdc1caf8241b5fb934354deb9ffe98 (patch) | |
tree | ae3c00f5a11c32895f07b10349dd252072f69689 /vespamalloc | |
parent | 3e2c8d0b5ae4ff54dff84cddc373b8aaa18b3000 (diff) |
Guard against smarter compiler.
Diffstat (limited to 'vespamalloc')
-rw-r--r-- | vespamalloc/src/tests/overwrite/overwrite.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
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; } |