Fixed a couple of null pointer problems

There were two null pointers causing it to dump core.  I realize the
code doesn't actually do anything, but still.
This commit is contained in:
Melinda Shore 2013-06-16 18:00:54 -08:00
parent b3ed4429d6
commit 096d4e5b77
1 changed files with 12 additions and 10 deletions

View File

@ -43,7 +43,7 @@ int main()
/* Be sure the search returned something */ /* Be sure the search returned something */
uint32_t * this_error = NULL; uint32_t * this_error = NULL;
this_ret = getdns_dict_get_int(this_response, "status", this_error); // Ignore any error this_ret = getdns_dict_get_int(this_response, "status", this_error); // Ignore any error
if (*this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good" if (this_error && (*this_error != GETDNS_RESPSTATUS_GOOD)) // If the search didn't return "good"
{ {
fprintf(stderr, "The search had no results, and a return value of %d. Exiting.", *this_error); fprintf(stderr, "The search had no results, and a return value of %d. Exiting.", *this_error);
return(GETDNS_RETURN_GENERIC_ERROR); return(GETDNS_RETURN_GENERIC_ERROR);
@ -53,6 +53,7 @@ int main()
size_t * num_addresses_ptr = NULL; size_t * num_addresses_ptr = NULL;
this_ret = getdns_list_get_length(just_the_addresses_ptr, num_addresses_ptr); // Ignore any error this_ret = getdns_list_get_length(just_the_addresses_ptr, num_addresses_ptr); // Ignore any error
/* Go through each record */ /* Go through each record */
if (num_addresses_ptr) {
for ( size_t rec_count = 0; rec_count <= *num_addresses_ptr; ++rec_count ) for ( size_t rec_count = 0; rec_count <= *num_addresses_ptr; ++rec_count )
{ {
struct getdns_dict * this_address; struct getdns_dict * this_address;
@ -63,6 +64,7 @@ int main()
printf("The address is %s", getdns_display_ip_address(this_address_data)); printf("The address is %s", getdns_display_ip_address(this_address_data));
} }
} }
}
/* Clean up */ /* Clean up */
getdns_context_destroy(this_context); getdns_context_destroy(this_context);
getdns_free_sync_request_memory(this_response); getdns_free_sync_request_memory(this_response);