diff --git a/src/dict.c b/src/dict.c index 2d78e5f8..6d7a89ea 100644 --- a/src/dict.c +++ b/src/dict.c @@ -660,6 +660,10 @@ getdns_pretty_print_dict(struct getdns_dict *dict) ldns_buffer *buf; char *ret; + if (!dict) { + return NULL; + } + buf = ldns_buffer_new(100); if (! buf) return NULL; diff --git a/src/example/example_all_functions.c b/src/example/example_all_functions.c index eb81736c..24367269 100644 --- a/src/example/example_all_functions.c +++ b/src/example/example_all_functions.c @@ -89,10 +89,6 @@ retregular = getdns_context_create( boolarg ); -getdns_context_destroy( - contextarg -); - retregular = getdns_cancel_callback( contextarg, txidarg @@ -150,18 +146,19 @@ retregular = getdns_dict_get_bindata(dictarg, charstararg, bindataptrarg); retregular = getdns_dict_get_int(dictarg, charstararg, uint32ptrarg); listarg = getdns_list_create(); -getdns_list_destroy(listarg); retregular = getdns_list_set_dict(listarg, sizetarg, dictarg); retregular = getdns_list_set_list(listarg, sizetarg, listarg); retregular = getdns_list_set_bindata(listarg, sizetarg, bindataarg); retregular = getdns_list_set_int(listarg, sizetarg, uint32arg); dictarg = getdns_dict_create(); -getdns_dict_destroy(dictarg); retregular = getdns_dict_set_dict(dictarg, charstararg, dictarg); retregular = getdns_dict_set_list(dictarg, charstararg, listarg); retregular = getdns_dict_set_bindata(dictarg, charstararg, bindataarg); retregular = getdns_dict_set_int(dictarg, charstararg, uint32arg); +retcharstar = getdns_pretty_print_dict( + dictarg +); retcharstar = getdns_convert_fqdn_to_dns_name( charstararg @@ -185,10 +182,6 @@ retregular = getdns_validate_dnssec( listarg ); -retcharstar = getdns_pretty_print_dict( - dictarg -); - retcharstar = getdns_display_ip_address( bindataarg ); @@ -294,4 +287,8 @@ retregular = getdns_context_set_memory_reallocator( deallocfunctionarg ); +getdns_list_destroy(listarg); +getdns_dict_destroy(dictarg); +getdns_context_destroy(contextarg); + return(0); } /* End of main() */ diff --git a/src/general.c b/src/general.c index 2e59af63..13c8c294 100644 --- a/src/general.c +++ b/src/general.c @@ -201,6 +201,10 @@ getdns_general_ub(struct ub_ctx* unbound, getdns_return_t gr; int r; + if (!name) { + return GETDNS_RETURN_GENERIC_ERROR; + } + gr = getdns_context_prepare_for_resolution(context); if (gr != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_BAD_CONTEXT;