diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-03-17 21:49:30 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-03-17 21:49:30 +0000 |
commit | 2122c205e677a0da93b582b148b6495b660e1e6d (patch) | |
tree | 7c8b7db988c167cc9b15006a010be15b64211082 /main/netsock2.c | |
parent | 94fe4a91781e8f21936cb382c8ecedf1bead44c1 (diff) |
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().
* Made functions that call ast_sockaddr_resolve() with RAII_VAR()
controlling the addrs variable use ast_free instead of ast_free_ptr to
provide better MALLOC_DEBUG information.
Review: https://reviewboard.asterisk.org/r/4509/
........
Merged revisions 433056 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433057 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/netsock2.c')
-rw-r--r-- | main/netsock2.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/main/netsock2.c b/main/netsock2.c index 0e83f27cf..8d36805f9 100644 --- a/main/netsock2.c +++ b/main/netsock2.c @@ -287,11 +287,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; } @@ -302,6 +304,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; } @@ -311,6 +314,7 @@ int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, } if (res_cnt == 0) { + *addrs = NULL; goto cleanup; } |