diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-01-27 11:40:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-27 11:40:34 +0100 |
commit | 752c1ee0e3800ab06ea213b56dd9893bc1890710 (patch) | |
tree | e51dd62738d52d59e159381107146d7b522c04e8 /vespamalloc/src | |
parent | 40ac8889856b1999c1647405081ae90a5130497c (diff) | |
parent | e57bf03885fdc1caf8241b5fb934354deb9ffe98 (diff) |
Merge pull request #11950 from vespa-engine/toregge/guard-against-smarter-compiler
Guard against smarter compiler.
Diffstat (limited to 'vespamalloc/src')
-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; } |