From c4cc75482fd6846163cafa79e98abb11bcfaf3d3 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 1 Feb 2000 01:58:26 +0000 Subject: [PATCH] Add missing malloc failure check Correctly NULL second entry in he->h_addr_list on get*byaddr. --- lib/lwres/getipnode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c index 6cf0bd468a..aeb9646b5f 100644 --- a/lib/lwres/getipnode.c +++ b/lib/lwres/getipnode.c @@ -625,11 +625,13 @@ hostfromaddr(lwres_gnbaresponse_t *addr, int af, const void *src) { /* copy address */ he->h_addr_list = malloc(sizeof(char *) * 2); + if (he->h_addr_list == NULL) + goto cleanup; he->h_addr_list[0] = malloc(he->h_length); if (he->h_addr_list[0] == NULL) goto cleanup; memcpy(he->h_addr_list[0], src, he->h_length); - he->h_addr_list[i] = NULL; + he->h_addr_list[1] = NULL; return (he); cleanup: