From 17cd5abb22291f512d86ab4cd4065f7fbab058d9 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Sat, 24 Mar 2012 02:33:36 +0000 Subject: [PATCH] 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 --- main/ast_expr2.y | 3 +++ 1 file changed, 3 insertions(+) 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); }