diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-24 17:11:18 +0000 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-12-24 17:11:18 +0000 |
commit | cedda2084d2f6b331ba0a73e05f0b77ee7995c86 (patch) | |
tree | 8a91fd88b2ce655780f3399954c7c37d2c368b95 /jv_alloc.c | |
parent | 0fed03f35a63c01e89c0ba91cfe92dfc226d1e86 (diff) |
Sneaky valgrind trick to detect stack memory issues.
After something is popped from a stack, we overwrite the memory
with uninitialised data (if JQ_DEBUG is on). This means that
valgrind reports use-after-pop as an uninitialised memory error.
Diffstat (limited to 'jv_alloc.c')
-rw-r--r-- | jv_alloc.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -26,3 +26,12 @@ void* jv_mem_realloc(void* p, size_t sz) { } return p; } + +#if JQ_DEBUG +volatile char jv_mem_uninitialised; +__attribute__((constructor)) void jv_mem_uninit_setup(){ + char* p = malloc(1); + jv_mem_uninitialised = *p; + free(p); +} +#endif |