summaryrefslogtreecommitdiff
path: root/rr.c
diff options
context:
space:
mode:
authorWillem Toorop <willem@NLnetLabs.nl>2012-08-24 15:26:41 +0200
committerWillem Toorop <willem@NLnetLabs.nl>2012-08-24 15:26:41 +0200
commitd1024a4ab37a4a72fb382568bac48a80ea5ab0fc (patch)
tree794ef6d83516dfd6ccd0452bb4062c1384faf47a /rr.c
parentcc6b4e73cd401ad01b4456b6453a77c2ee856d5b (diff)
downloadldns-d1024a4ab37a4a72fb382568bac48a80ea5ab0fc.tar.gz
Changes from codereview from CZ.NIC and Paul Wouters
- use of pkt pointer before test for NULL in ldns_dnssec_build_data_chain - Memory leak on memory error in ldns_tsig_mac_new - Smaller stack ocuupation in read_key_file in drill_util.c - Potential for filedescriptor leak in ldns_init_random - Memory leak on memory error in ldns_str2rdf_apl - Memory leak (not freeing hexdata) in ldns_rr_new_frm_str_internal - Memory leak when testing for parse in ldns_rr_new_frm_str_interal - Memory leak when testing for parse in ldns_rr_new_frm_fp_l - Memory leak on memory error in ldns_rr_list_sort - Memory leak when popping zero items with ldns_rr_list_pop_rr_list
Diffstat (limited to 'rr.c')
-rw-r--r--rr.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/rr.c b/rr.c
index 0254d476..72076d40 100644
--- a/rr.c
+++ b/rr.c
@@ -477,6 +477,7 @@ ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str,
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
ldns_rr_free(new);
+ LDNS_FREE(hex_data);
return s;
}
LDNS_FREE(hex_data);
@@ -600,6 +601,9 @@ ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str,
if (newrr) {
*newrr = new;
+ } else {
+ /* Maybe the caller just wanted to see if it would parse? */
+ ldns_rr_free(new);
}
return LDNS_STATUS_OK;
@@ -724,8 +728,13 @@ ldns_rr_new_frm_fp_l(ldns_rr **newrr, FILE *fp, uint32_t *default_ttl, ldns_rdf
}
}
LDNS_FREE(line);
- if (newrr && s == LDNS_STATUS_OK) {
- *newrr = rr;
+ if (s == LDNS_STATUS_OK) {
+ if (newrr) {
+ *newrr = rr;
+ } else {
+ /* Just testing if it would parse? */
+ ldns_rr_free(rr);
+ }
}
return s;
}
@@ -1156,7 +1165,8 @@ ldns_rr_list_pop_rr_list(ldns_rr_list *rr_list, size_t howmany)
i--;
}
- if (i == howmany) {
+ if (i == howmany) { /* so i <= 0 */
+ ldns_rr_list_free(popped);
return NULL;
} else {
return popped;
@@ -1480,6 +1490,7 @@ ldns_rr_list_sort(ldns_rr_list *unsorted)
LDNS_FREE(sortables[i]);
}
/* no way to return error */
+ LDNS_FREE(sortables);
return;
}
sortables[i]->original_object = ldns_rr_list_rr(unsorted, i);