# HG changeset patch # User Mike Becker # Date 1747316610 -7200 # Node ID eeb2fc3850e2166dd01c82a307a32280a8007f60 # Parent c41538edfcef4c26479b3ee93284729a3ffd68a8 fix that testing allocator is counting free(NULL) diff -r c41538edfcef -r eeb2fc3850e2 tests/util_allocator.c --- a/tests/util_allocator.c Sun May 04 17:22:30 2025 +0200 +++ b/tests/util_allocator.c Thu May 15 15:43:30 2025 +0200 @@ -80,16 +80,18 @@ static void *cx_realloc_testing(void *d, void *mem, size_t n) { CxTestingAllocator *data = d; void *ptr = realloc(mem, n); - if (ptr == mem) { + if (mem != NULL && ptr == mem) { return ptr; } else { data->alloc_total++; if (ptr == NULL) { data->alloc_failed++; } else { - data->free_total++; - if (!cx_testing_allocator_untrack(data, mem)) { - data->free_failed++; + if (mem != NULL) { + data->free_total++; + if (!cx_testing_allocator_untrack(data, mem)) { + data->free_failed++; + } } cx_testing_allocator_track(data, ptr); } @@ -110,6 +112,7 @@ } static void cx_free_testing(void *d, void *mem) { + if (mem == NULL) return; CxTestingAllocator *data = d; data->free_total++; if (cx_testing_allocator_untrack(data, mem)) {