]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
higher.c: don't try to free unallocated memory
authorPhilip Paeps <philip@trouble.is>
Mon, 25 Apr 2016 06:25:17 +0000 (11:55 +0530)
committerWillem Toorop <willem@nlnetlabs.nl>
Tue, 26 Apr 2016 10:37:33 +0000 (12:37 +0200)
ldns_rr_new_frm_str() will only return an allocated rr if if can
successfully parse the string.  Don't try to free rr unless this is the
case.  Some malloc implementations (e.g. Mac OS X) crash when trying to
free unallocated memory.

higher.c

index e3077aeec923d00dab82051816cad04565844ea0..528283ce886f522e22a4754148894f689c9b33ae 100644 (file)
--- a/higher.c
+++ b/higher.c
@@ -227,8 +227,8 @@ ldns_get_rr_list_hosts_frm_fp_l(FILE *fp, int *line_nr)
                                parse_result = ldns_rr_new_frm_str(&rr, rr_str, 0, NULL, NULL);
                                if (parse_result == LDNS_STATUS_OK && ldns_rr_owner(rr) && ldns_rr_rd_count(rr) > 0) {
                                        ldns_rr_list_push_rr(list, ldns_rr_clone(rr));
+                                       ldns_rr_free(rr);
                                }
-                               ldns_rr_free(rr);
                        }
                }
                ldns_buffer_free(linebuf);