From cd37f120597acfbbedb2414d0cb8bf7c8407bffc Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Mon, 7 Jan 2013 08:24:40 +0100 Subject: [PATCH] core: fix memory leak in evaluation of expression when a logical operator ("&&" or "||") is found --- src/core/wee-eval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index a55daaff4..39203d5ed 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -569,6 +569,8 @@ eval_expression_internal (const char *expr, struct t_hashtable *pointers, tmp_value = eval_expression_internal (sub_expr, pointers, extra_vars, 0); free (sub_expr); rc = eval_is_true (tmp_value); + if (tmp_value) + free (tmp_value); /* * if rc == 0 with "&&" or rc == 1 with "||", no need to evaluate * second sub-expression, just return the rc @@ -576,8 +578,6 @@ eval_expression_internal (const char *expr, struct t_hashtable *pointers, if ((!rc && (logic == EVAL_LOGICAL_OP_AND)) || (rc && (logic == EVAL_LOGICAL_OP_OR))) { - if (tmp_value) - free (tmp_value); value = strdup ((rc) ? EVAL_STR_TRUE : EVAL_STR_FALSE); goto end; }