From a93547affa0657a746c2771819c2a49c293ced2f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 19 Apr 2017 13:28:15 +0300 Subject: [PATCH] flow, db: fix how inline function assignments are handled The problem here is that big_expression_stack is really unreliable and we should probably just get rid of it. I think it was putting the inline statements on the stack so it was returning false instead of true. This is used in smatch_function_hooks and it means that we parse the call twice once as a function call and once as a function assignment call. It affected some new code I'm working on where it said that we're calling a function twice resulting in a double free. Signed-off-by: Dan Carpenter --- smatch_flow.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/smatch_flow.c b/smatch_flow.c index 3c723995..efdce266 100644 --- a/smatch_flow.c +++ b/smatch_flow.c @@ -153,15 +153,12 @@ static void set_parent_stmt(struct statement *stmt, struct statement *parent) int is_assigned_call(struct expression *expr) { - struct expression *tmp; + if (expr->parent && + expr->parent->type == EXPR_ASSIGNMENT && + expr->parent->op == '=' && + strip_expr(expr->parent->right) == expr) + return 1; - FOR_EACH_PTR_REVERSE(big_expression_stack, tmp) { - if (tmp->type == EXPR_ASSIGNMENT && tmp->op == '=' && - strip_expr(tmp->right) == expr) - return 1; - if (tmp->pos.line < expr->pos.line) - return 0; - } END_FOR_EACH_PTR_REVERSE(tmp); return 0; } -- 2.11.4.GIT