From a5bacfefcf84f4f15b22d9274b7d2e33dd0693c0 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Wed, 8 Jul 2015 11:07:44 +0200 Subject: [PATCH] memory leak fixes --- src/dnssec.c | 2 +- src/test/getdns_query.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/dnssec.c b/src/dnssec.c index 4d8ce1df..1932c351 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -2928,7 +2928,7 @@ getdns_root_trust_anchor(time_t *utc_date_of_anchor) if (!_getdns_parse_ta_file(utc_date_of_anchor, gbuf)) goto error_free_gbuf; - _getdns_wire2list( gldns_buffer_export(gbuf) + _getdns_wire2list( gldns_buffer_begin(gbuf) , gldns_buffer_position(gbuf), ta_rrs); gldns_buffer_free(gbuf); diff --git a/src/test/getdns_query.c b/src/test/getdns_query.c index fa6cf3d3..130fa3c7 100644 --- a/src/test/getdns_query.c +++ b/src/test/getdns_query.c @@ -180,16 +180,15 @@ static getdns_return_t validate_chain(getdns_dict *response) if (!(to_validate = getdns_list_create())) return GETDNS_RETURN_MEMORY_ERROR; - if (!(trust_anchor = getdns_root_trust_anchor(NULL))) - return GETDNS_RETURN_GENERIC_ERROR; + trust_anchor = getdns_root_trust_anchor(NULL); if ((r = getdns_dict_get_list( response, "validation_chain", &validation_chain))) - return r; + goto error; if ((r = getdns_dict_get_list( response, "replies_tree", &replies_tree))) - return r; + goto error; fprintf(stdout, "replies_tree %zu, dnssec_status: ", i); switch ((s = getdns_validate_dnssec( @@ -218,7 +217,7 @@ static getdns_return_t validate_chain(getdns_dict *response) while (!(r = getdns_list_get_dict(replies_tree, i++, &reply))) { if ((r = getdns_list_set_dict(to_validate, 0, reply))) - return r; + goto error; fprintf( stdout , "reply %zu, dnssec_status: ", i); @@ -244,8 +243,11 @@ static getdns_return_t validate_chain(getdns_dict *response) fprintf(stdout, "%d\n", (int)s); } } - if (r != GETDNS_RETURN_NO_SUCH_LIST_ITEM) - return r; + if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM) + r = GETDNS_RETURN_GOOD; +error: + getdns_list_destroy(trust_anchor); + getdns_list_destroy(to_validate); return GETDNS_RETURN_GOOD; }