]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Remove some memory leaks
authorWillem Toorop <willem@nlnetlabs.nl>
Fri, 12 Jul 2024 14:08:57 +0000 (16:08 +0200)
committerWillem Toorop <willem@nlnetlabs.nl>
Fri, 12 Jul 2024 14:08:57 +0000 (16:08 +0200)
Still zome left in ldns-verify-zone, but leaving it for now

test/16-unit-tests-edns.tpkg/16-unit-tests-edns.c

index aaa90317679ad43604c4ad9d570632bf7268c653..54cde28e0178340f9273b3da08eed2a2799d34b7 100644 (file)
@@ -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);