From: Alan T. DeKok Date: Sun, 29 Mar 2026 19:22:07 +0000 (-0400) Subject: decrease reference count, so that memory is freed X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eba7faa0ca667db2b142645aa51560042dbaf5ea;p=thirdparty%2Ffreeradius-server.git decrease reference count, so that memory is freed --- diff --git a/src/lib/util/test/talloc_tests.c b/src/lib/util/test/talloc_tests.c index 16550f9d083..8ee735d954e 100644 --- a/src/lib/util/test/talloc_tests.c +++ b/src/lib/util/test/talloc_tests.c @@ -691,7 +691,21 @@ static void test_talloc_increase_ref_count(void) TEST_CHECK(ret == 0); TEST_CHECK(talloc_reference_count(str) == 2); - talloc_free(ctx); + /* + * And then decrease it to be safe. + */ + ret = talloc_decrease_ref_count(str); + TEST_CHECK(ret == 2); // WAS 2 + TEST_CHECK(talloc_reference_count(str) == 1); // NOW 1 + + ret = talloc_decrease_ref_count(str); + TEST_CHECK(ret == 1); // WAS 1, now 0 and freed + + ret = talloc_total_blocks(ctx); + TEST_CHECK(ret == 1); // just ctx itself + + ret = talloc_free(ctx); + TEST_CHECK(ret == 0); } /*