Valgrind found some memory leaks associated with ast_sockaddr_resolve().
Most of the leaks had already been fixed by earlier memory leak hunt
patches. This patch performs an audit of ast_sockaddr_resolve() and found
one more.
* Fix ast_sockaddr_resolve() memory leak in
apps/app_externalivr.c:app_exec().
* Made main/netsock2.c:ast_sockaddr_resolve() always set the addrs
parameter for safety so the pointer will never be uninitialized on return.
The same goes for res/res_pjsip_acl.c:extract_contact_addr().
Review: https://reviewboard.asterisk.org/r/4509/
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@433056
65c4cc65-6c06-0410-ace0-
fbb531ad65f3
break;
}
+ ast_free(addrs);
+
if (i == num_addrs) {
ast_chan_log(LOG_ERROR, chan, "Could not connect to any host. ExternalIVR failed.\n");
goto exit;
int e, i, res_cnt;
if (!str) {
+ *addrs = NULL;
return 0;
}
s = ast_strdupa(str);
if (!ast_sockaddr_split_hostport(s, &host, &port, flags)) {
+ *addrs = NULL;
return 0;
}
if ((e = getaddrinfo(host, port, &hints, &res))) {
ast_log(LOG_ERROR, "getaddrinfo(\"%s\", \"%s\", ...): %s\n",
host, S_OR(port, "(null)"), gai_strerror(e));
+ *addrs = NULL;
return 0;
}
}
if (res_cnt == 0) {
+ *addrs = NULL;
goto cleanup;
}