diff --git a/src/context.c b/src/context.c index 44b42ef4..967b729f 100644 --- a/src/context.c +++ b/src/context.c @@ -3158,24 +3158,31 @@ _get_context_settings(getdns_context* context) } getdns_dict* -getdns_context_get_api_information(getdns_context* context) { - getdns_return_t r = GETDNS_RETURN_GOOD; - getdns_dict* result = getdns_dict_create_with_context(context); - getdns_dict* settings; - if (!result) { - return NULL; - } - r = getdns_dict_util_set_string(result, "version_string", GETDNS_VERSION); - r |= getdns_dict_util_set_string(result, "implementation_string", PACKAGE_URL); - r |= getdns_dict_set_int(result, "resolution_type", context->resolution_type); - settings = _get_context_settings(context); - r |= getdns_dict_set_dict(result, "all_context", settings); - getdns_dict_destroy(settings); - if (r != GETDNS_RETURN_GOOD) { - getdns_dict_destroy(result); - result = NULL; - } - return result; +getdns_context_get_api_information(getdns_context* context) +{ + getdns_dict* result; + getdns_dict* settings; + + if ((result = getdns_dict_create_with_context(context)) + + && ! getdns_dict_util_set_string( + result, "version_string", GETDNS_VERSION) + + && ! getdns_dict_util_set_string( + result, "implementation_string", PACKAGE_URL) + + && ! getdns_dict_set_int( + result, "resolution_type", context->resolution_type) + + && (settings = _get_context_settings(context))) { + + if (!_getdns_dict_set_this_dict(result,"all_context",settings)) + return result; + + getdns_dict_destroy(settings); + } + getdns_dict_destroy(result); + return NULL; } getdns_return_t diff --git a/src/convert.c b/src/convert.c index 02d73753..8e69309c 100644 --- a/src/convert.c +++ b/src/convert.c @@ -637,9 +637,8 @@ _getdns_wire2msg_dict_scan(struct mem_funcs *mf, SET_WIRE_CNT(arcount, ARCOUNT); /* header */ - if ((r = getdns_dict_set_dict(result, "header", header))) + if ((r = _getdns_dict_set_this_dict(result, "header", header))) goto error; - getdns_dict_destroy(header); header = NULL; eop = *wire + 12; @@ -655,7 +654,7 @@ _getdns_wire2msg_dict_scan(struct mem_funcs *mf, switch ((section = _getdns_rr_iter_section(rr_iter))) { case GLDNS_SECTION_QUESTION: - if ((r = getdns_dict_set_dict( + if ((r = _getdns_dict_set_this_dict( result, "question", rr_dict))) goto error; break; @@ -663,6 +662,7 @@ _getdns_wire2msg_dict_scan(struct mem_funcs *mf, if ((r = _getdns_list_append_dict( sections[section], rr_dict))) goto error; + getdns_dict_destroy(rr_dict); break; } rr_dict = NULL; diff --git a/src/util-internal.c b/src/util-internal.c index 90c8be1e..bbc5bc7c 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -376,10 +376,9 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) getdns_list_destroy(repeat_list); repeat_list = NULL; } - if (getdns_dict_set_dict(rr_dict, "rdata", rdata_dict)) + if (_getdns_dict_set_this_dict(rr_dict, "rdata", rdata_dict)) goto rdata_error; - getdns_dict_destroy(rdata_dict); return rr_dict; rdata_error: @@ -529,8 +528,9 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req, SET_WIRE_CNT(arcount, ARCOUNT); /* header */ - if ((r = getdns_dict_set_dict(result, "header", header))) + if ((r = _getdns_dict_set_this_dict(result, "header", header))) goto error; + header = NULL; canonical_name = req->owner->name; canonical_name_len = req->owner->name_len; @@ -548,9 +548,10 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req, section = _getdns_rr_iter_section(rr_iter); if (section == GLDNS_SECTION_QUESTION) { - if (getdns_dict_set_dict(result, "question", rr_dict)) + if (_getdns_dict_set_this_dict(result, "question", rr_dict)) goto error; + rr_dict = NULL; continue; } if (_getdns_list_append_dict(sections[section], rr_dict)) @@ -788,7 +789,7 @@ _getdns_create_call_reporting_dict( _getdns_sockaddr_to_dict( context, &netreq->upstream->addr, &address_debug); - if (getdns_dict_set_dict(netreq_debug, "query_to", address_debug)) { + if (_getdns_dict_set_this_dict(netreq_debug,"query_to",address_debug)){ getdns_dict_destroy(address_debug); return NULL; } @@ -802,8 +803,6 @@ _getdns_create_call_reporting_dict( getdns_dict_destroy(netreq_debug); return NULL; } - getdns_dict_destroy(address_debug); - if (transport != GETDNS_TRANSPORT_UDP) { /* Report the idle timeout actually used on the connection. Must trim, maximum used in practice is 6553500ms, but this is stored in a uint64_t.*/