On realloc failure the old value is still around
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
for (res = ailist; res; res = res->ai_next) {
struct sockaddr_storage ss = {0};
+ struct sockaddr_storage *tmp = NULL;
if ((res->ai_addr == NULL) ||
(res->ai_addrlen == 0) ||
}
ret_count += 1;
- iplist = talloc_realloc(
+ tmp = talloc_realloc(
mem_ctx, iplist, struct sockaddr_storage,
ret_count);
- if (iplist == NULL) {
+ if (tmp == NULL) {
DEBUG(3,("resolve_hosts: malloc fail !\n"));
freeaddrinfo(ailist);
return NT_STATUS_NO_MEMORY;
}
+ iplist = tmp;
iplist[i] = ss;
i++;
}