summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2009-06-18 16:37:42 +0000
committerDavid Vossel <dvossel@digium.com>2009-06-18 16:37:42 +0000
commitdcfe69ec6454cecae1d6c25bbaf33e26a531b3ff (patch)
tree9e55718a16861e122cd8aed23e4b4f0369fdec92 /main
parent730e60e583292b45b175a021fef98a5066f0827f (diff)
fixes some memory leaks and redundant conditions
(closes issue #15269) Reported by: contactmayankjain Patches: patch.txt uploaded by contactmayankjain (license 740) memory_leak_stuff.trunk.diff uploaded by dvossel (license 671) Tested by: contactmayankjain, dvossel git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@201678 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r--main/ast_expr2.c1
-rw-r--r--main/ast_expr2f.c5
-rw-r--r--main/asterisk.c3
3 files changed, 4 insertions, 5 deletions
diff --git a/main/ast_expr2.c b/main/ast_expr2.c
index 4dcda2e3b..d9abfc10f 100644
--- a/main/ast_expr2.c
+++ b/main/ast_expr2.c
@@ -2415,6 +2415,7 @@ static void
free_value (struct val *vp)
{
if (vp==NULL) {
+ free(vp);
return;
}
if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
diff --git a/main/ast_expr2f.c b/main/ast_expr2f.c
index 15dbb5c2e..db09f28de 100644
--- a/main/ast_expr2f.c
+++ b/main/ast_expr2f.c
@@ -2379,7 +2379,7 @@ int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
void ast_yyfree(void *ptr, yyscan_t yyscanner)
{
- if (ptr) /* the normal generated ast_yyfree func just frees its first arg;
+ /* the normal generated ast_yyfree func just frees its first arg;
this get complaints on some systems, as sometimes this
arg is a nil ptr! It's usually not fatal, but is irritating! */
free( (char *) ptr );
@@ -2416,8 +2416,7 @@ int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
else
buf[0] = 0;
return_value = strlen(buf);
- if (io.val->u.s)
- free(io.val->u.s);
+ free(io.val->u.s);
}
free(io.val);
}
diff --git a/main/asterisk.c b/main/asterisk.c
index a756b305b..e83534787 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -941,8 +941,7 @@ void ast_unregister_atexit(void (*func)(void))
AST_RWLIST_TRAVERSE_SAFE_END;
AST_RWLIST_UNLOCK(&atexits);
- if (ae)
- free(ae);
+ free(ae);
}
/* Sending commands from consoles back to the daemon requires a terminating NULL */