From 6d6cd660465080d61923382fde26552f10b8e3df Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 2 Jun 2019 14:05:36 -0400 Subject: [PATCH] Freed defers after they run. Apparently this is sufficient to satisfy AddressSanitizer, which... how? I'll take it, but still, there's definitely more unfreed allocations than this... --- test/lib/testing.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/lib/testing.c b/test/lib/testing.c index 599d7857..c288086c 100644 --- a/test/lib/testing.c +++ b/test/lib/testing.c @@ -111,6 +111,13 @@ static void runDefers(testingT *t) t->defersRun = true; for (d = t->defers; d != NULL; d = d->next) (*(d->f))(t, d->data); + // and now free the defers + // we could use t->defers == NULL instead of t->defersRun but then recursive calls to runDefers() (for instance, if a deferred function calls testingTFatalf()) would explode + while (t->defers != NULL) { + d = t->defers; + t->defers = t->defers->next; + testingprivFree(d); + } } static const testingOptions defaultOptions = {