From: Russell Bryant Date: Sat, 24 Mar 2012 02:33:36 +0000 (+0000) Subject: expression parser: Fix (theoretical) memory leak. X-Git-Tag: 1.8.11.0~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17cd5abb22291f512d86ab4cd4065f7fbab058d9;p=thirdparty%2Fasterisk.git 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. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@360356 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/ast_expr2.y b/main/ast_expr2.y index aabca8a463..64031dd656 100644 --- a/main/ast_expr2.y +++ b/main/ast_expr2.y @@ -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); }