Some minor getdns_query memory leak fixes

This commit is contained in:
Willem Toorop 2016-06-21 16:31:07 +02:00
parent 3cc369a27d
commit f5d31cd93c
1 changed files with 19 additions and 4 deletions

View File

@ -504,8 +504,9 @@ getdns_return_t parse_args(int argc, char **argv)
fprintf(stderr, "Could not create upstream list\n"); fprintf(stderr, "Could not create upstream list\n");
return GETDNS_RETURN_MEMORY_ERROR; return GETDNS_RETURN_MEMORY_ERROR;
} }
getdns_list_set_dict(upstream_list, (void) getdns_list_set_dict(upstream_list,
upstream_count++, upstream); upstream_count++, upstream);
getdns_dict_destroy(upstream);
} }
continue; continue;
} else if (arg[0] == '{') { } else if (arg[0] == '{') {
@ -930,15 +931,26 @@ next: ;
context, upstream_list))) { context, upstream_list))) {
fprintf(stderr, "Error setting upstream recursive servers\n"); fprintf(stderr, "Error setting upstream recursive servers\n");
} }
if (upstream_list)
getdns_list_destroy(upstream_list);
if (print_api_info) { if (print_api_info) {
fprintf(stdout, "%s\n", getdns_pretty_print_dict( getdns_dict *api_information =
getdns_context_get_api_information(context))); getdns_context_get_api_information(context);
char *api_information_str =
getdns_pretty_print_dict(api_information);
fprintf(stdout, "%s\n", api_information_str);
free(api_information_str);
getdns_dict_destroy(api_information);
return CONTINUE; return CONTINUE;
} }
if (print_trust_anchors) { if (print_trust_anchors) {
if (!getdns_context_get_dnssec_trust_anchors(context, &tas)) { if (!getdns_context_get_dnssec_trust_anchors(context, &tas)) {
/* if ((tas = getdns_root_trust_anchor(NULL))) { */ /* if ((tas = getdns_root_trust_anchor(NULL))) { */
fprintf(stdout, "%s\n", getdns_pretty_print_list(tas)); char *tas_str = getdns_pretty_print_list(tas);
fprintf(stdout, "%s\n", tas_str);
free(tas_str);
getdns_list_destroy(tas);
return CONTINUE; return CONTINUE;
} else } else
return CONTINUE_ERROR; return CONTINUE_ERROR;
@ -1403,6 +1415,9 @@ main(int argc, char **argv)
done_destroy_context: done_destroy_context:
getdns_context_destroy(context); getdns_context_destroy(context);
if (listen_list)
getdns_list_destroy(listen_list);
if (fp) if (fp)
fclose(fp); fclose(fp);