Audit ast_sockaddr_resolve() usage for memory leaks.

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
changes/61/61/1
Richard Mudgett 10 years ago
parent 19e5630c50
commit 4f68f39cde

@ -519,6 +519,8 @@ static int app_exec(struct ast_channel *chan, const char *data)
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;

@ -253,11 +253,13 @@ int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str,
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;
}
@ -268,6 +270,7 @@ int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str,
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;
}
@ -277,6 +280,7 @@ int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str,
}
if (res_cnt == 0) {
*addrs = NULL;
goto cleanup;
}

Loading…
Cancel
Save