[asterisk-commits] russell: branch 1.8 r360356 - /branches/1.8/main/ast_expr2.y

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 23 21:33:40 CDT 2012


Author: russell
Date: Fri Mar 23 21:33:36 2012
New Revision: 360356

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=360356
Log:
expression parser: Fix (theoretical) memory leak.

Fix a memory leak that is very unlikely to actually happen.  If a malloc()
succeeded, but the following strdup() failed, the memory from the original
malloc() would be leaked.

Modified:
    branches/1.8/main/ast_expr2.y

Modified: branches/1.8/main/ast_expr2.y
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/ast_expr2.y?view=diff&rev=360356&r1=360355&r2=360356
==============================================================================
--- branches/1.8/main/ast_expr2.y (original)
+++ branches/1.8/main/ast_expr2.y Fri Mar 23 21:33:36 2012
@@ -532,6 +532,9 @@
 
 	vp = (struct val *) malloc (sizeof (*vp));
 	if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) {
+		if (vp) {
+			free(vp);
+		}
 		ast_log(LOG_WARNING,"malloc() failed\n");
 		return(NULL);
 	}




More information about the asterisk-commits mailing list