From 28bb3ffac9dd7337bc48d3c31974efa580e28629 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 12 Jul 2024 16:08:57 +0200 Subject: [PATCH] Remove some memory leaks Still zome left in ldns-verify-zone, but leaving it for now --- test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c index aaa90317..54cde28e 100644 --- a/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c +++ b/test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c @@ -78,7 +78,7 @@ check_option(void) return 0; } - ldns_edns_free(edns); + ldns_edns_deep_free(edns); edns = ldns_edns_new_from_data(LDNS_EDNS_EDE, 4, hex_data); @@ -94,7 +94,6 @@ check_option(void) ldns_edns_deep_free(edns); ldns_edns_deep_free(clone); - return 1; } @@ -185,6 +184,7 @@ check_option_list(void) if (ldns_buffer_read_u8(buf) != hex_data[i]) { printf("Error: EDNS data is incorrect: %d, %d\n", ldns_buffer_read_u8_at(buf, i), hex_data[i]); + ldns_buffer_free(buf); return 0; } } @@ -195,9 +195,12 @@ check_option_list(void) if (ldns_buffer_read_u8(buf) != hex_data2[i]) { printf("Error: EDNS data is incorrect: %d, %d\n", ldns_buffer_read_u8_at(buf, i), hex_data2[i]); + ldns_buffer_free(buf); return 0; } } + ldns_buffer_free(buf); + buf = NULL; /* Replace the first option with a copy of the second */ option = ldns_edns_new_from_data(LDNS_EDNS_PADDING, 5, hex_data2); @@ -232,6 +235,7 @@ check_option_list(void) if (!(check_option_list_entries(clone, option, 1, LDNS_EDNS_PADDING, 5, hex_data2))) { printf("Error: EDNS list entries are incorrect\n"); + ldns_edns_option_list_deep_free(clone); return 0; } @@ -245,7 +249,7 @@ check_option_list(void) return 0; } - ldns_edns_option_list_free(clone); + ldns_edns_option_list_deep_free(clone); ldns_edns_option_list_deep_free(list);