fence-virt: Fix null pointer deref

Fix an unlikely null pointer dereference that could occur
subsequent to malloc failing.

Signed-off-by: Ryan McCabe <rmccabe@redhat.com>
This commit is contained in:
Ryan McCabe 2012-10-17 11:03:57 -04:00
parent 0c502aad77
commit c48c06819f

View File

@ -82,13 +82,13 @@ add_ip(ip_list_t *ipl, char *ipaddr, char family)
return -1;
}
dbg_printf(4, "Adding IP %s to list (family %d)\n", ipaddr, family);
ipa = malloc(sizeof(*ipa));
memset(ipa, 0, sizeof(*ipa));
ipa = calloc(1, sizeof(*ipa));
if (!ipa)
return -1;
ipa->ipa_family = family;
ipa->ipa_address = strdup(ipaddr);
dbg_printf(4, "Adding IP %s to list (family %d)\n", ipaddr, family);
TAILQ_INSERT_TAIL(ipl, ipa, ipa_entries);
return 0;