diff options
author | David Robillard <d@drobilla.net> | 2019-10-18 18:34:45 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-10-18 20:15:53 +0200 |
commit | ab1eae13ea414e4e4647b27fc89d2020f91680ce (patch) | |
tree | 35cc1e4796da076d0888e98e4d6a04bd3f500e04 /test/test_malloc.c | |
parent | fd6ff412c6c25bcbc71985ba08f3654cbf621f5a (diff) | |
download | zix-ab1eae13ea414e4e4647b27fc89d2020f91680ce.tar.gz zix-ab1eae13ea414e4e4647b27fc89d2020f91680ce.tar.bz2 zix-ab1eae13ea414e4e4647b27fc89d2020f91680ce.zip |
Fix strange bug in test malloc
With a certain program, this was failing to use the local malloc in the call
stack of the dlsym, which resulted in an infinite recursion and crash. I have
no idea why, other than the optimizer is somehow at fault. This fixes it.
Diffstat (limited to 'test/test_malloc.c')
-rw-r--r-- | test/test_malloc.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/test/test_malloc.c b/test/test_malloc.c index 202db30..5803f93 100644 --- a/test/test_malloc.c +++ b/test/test_malloc.c @@ -29,8 +29,8 @@ static size_t test_malloc_n_allocs = 0; static size_t test_malloc_fail_after = (size_t)-1; static volatile bool in_test_malloc_init = false; -void* -malloc(size_t size) +static void* +test_malloc(size_t size) { if (in_test_malloc_init) { return NULL; // dlsym is asking for memory, but handles this fine @@ -47,9 +47,15 @@ malloc(size_t size) } void* +malloc(size_t size) +{ + return test_malloc(size); +} + +void* calloc(size_t nmemb, size_t size) { - void* ptr = malloc(nmemb * size); + void* ptr = test_malloc(nmemb * size); if (ptr) { memset(ptr, 0, nmemb * size); } |