[asterisk-commits] rmudgett: branch 11 r433056 - in /branches/11: apps/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 17 16:43:37 CDT 2015


Author: rmudgett
Date: Tue Mar 17 16:43:32 2015
New Revision: 433056

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433056
Log:
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/

Modified:
    branches/11/apps/app_externalivr.c
    branches/11/main/netsock2.c

Modified: branches/11/apps/app_externalivr.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/apps/app_externalivr.c?view=diff&rev=433056&r1=433055&r2=433056
==============================================================================
--- branches/11/apps/app_externalivr.c (original)
+++ branches/11/apps/app_externalivr.c Tue Mar 17 16:43:32 2015
@@ -518,6 +518,8 @@
 			}
 			break;
 		}
+
+		ast_free(addrs);
 
 		if (i == num_addrs) {
 			ast_chan_log(LOG_ERROR, chan, "Could not connect to any host.  ExternalIVR failed.\n");

Modified: branches/11/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/netsock2.c?view=diff&rev=433056&r1=433055&r2=433056
==============================================================================
--- branches/11/main/netsock2.c (original)
+++ branches/11/main/netsock2.c Tue Mar 17 16:43:32 2015
@@ -253,11 +253,13 @@
 	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 @@
 	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 @@
 	}
 
 	if (res_cnt == 0) {
+		*addrs = NULL;
 		goto cleanup;
 	}
 




More information about the asterisk-commits mailing list