From: Alan T. DeKok Date: Sat, 13 Nov 2021 13:44:57 +0000 (-0500) Subject: if we free on abort, we might as well make commit into free X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32d628d61b36b116a3ccc14d44812735d3a4d71b;p=thirdparty%2Ffreeradius-server.git if we free on abort, we might as well make commit into free --- diff --git a/src/lib/util/edit.h b/src/lib/util/edit.h index 5d1902a115..d20d470168 100644 --- a/src/lib/util/edit.h +++ b/src/lib/util/edit.h @@ -37,6 +37,8 @@ fr_edit_list_t *fr_edit_list_alloc(TALLOC_CTX *ctx); void fr_edit_list_abort(fr_edit_list_t *el); +#define fr_edit_list_commit(_x) talloc_free(_x) + int fr_edit_list_insert_after(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *pos, fr_pair_t *vp) CC_HINT(nonnull(2,4)); int fr_edit_list_delete(fr_edit_list_t *el, fr_pair_list_t *list, fr_pair_t *vp) CC_HINT(nonnull(2,3)); diff --git a/src/lib/util/edit_tests.c b/src/lib/util/edit_tests.c index 253ebe0e7c..95c7ff3a7d 100644 --- a/src/lib/util/edit_tests.c +++ b/src/lib/util/edit_tests.c @@ -135,7 +135,7 @@ static void test_pair_delete_head(void) rcode = fr_edit_list_delete(el, &local_pairs, vp); TEST_CHECK(rcode == 0); - talloc_free(el); + fr_edit_list_commit(el); count = fr_pair_list_len(&local_pairs); TEST_CASE("Expected (count == 2) after deleting the head"); @@ -202,7 +202,7 @@ static void test_pair_delete_middle(void) rcode = fr_edit_list_delete(el, &local_pairs, vp); TEST_CHECK(rcode == 0); - talloc_free(el); + fr_edit_list_commit(el); /* let's count */ count = fr_pair_list_len(&local_pairs); @@ -287,7 +287,7 @@ static void test_pair_delete_multiple(void) rcode = fr_edit_list_delete(el, &local_pairs, vp); /* tail */ TEST_CHECK(rcode == 0); - talloc_free(el); + fr_edit_list_commit(el); count = fr_pair_list_len(&local_pairs); TEST_CASE("Expected (count == 1) after deleting the last 2"); @@ -374,7 +374,7 @@ static void test_pair_edit_value(void) vp->vp_uint32 = 1; TEST_CHECK(vp->vp_uint32 == 1); - talloc_free(el); + fr_edit_list_commit(el); vp = fr_pair_list_head(&local_pairs); TEST_CHECK(vp->da == fr_dict_attr_test_uint32); @@ -440,7 +440,7 @@ static void test_pair_insert_after_head(void) rcode = fr_edit_list_insert_after(el, &local_pairs, NULL, vp); TEST_CHECK(rcode == 0); - talloc_free(el); + fr_edit_list_commit(el); count = fr_pair_list_len(&local_pairs); TEST_CASE("Expected (count == 4) after inserting a new one"); @@ -509,7 +509,7 @@ static void test_pair_insert_after_middle(void) rcode = fr_edit_list_insert_after(el, &local_pairs, middle, vp); TEST_CHECK(rcode == 0); - talloc_free(el); + fr_edit_list_commit(el); count = fr_pair_list_len(&local_pairs); TEST_CASE("Expected (count == 4) after inserting a new one");