]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
expression parser: Fix (theoretical) memory leak.
authorRussell Bryant <russell@russellbryant.com>
Sat, 24 Mar 2012 02:33:36 +0000 (02:33 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sat, 24 Mar 2012 02:33:36 +0000 (02:33 +0000)
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.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@360356 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/ast_expr2.y

index aabca8a4634606fd58a3ea5ebb6032a2c2b8acbe..64031dd65620cce31089f020c5db4ca4416bab6a 100644 (file)
@@ -532,6 +532,9 @@ make_str (const char *s)
 
        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);
        }