From f9aadc13b56dee13a0bbfd1ec43ddcf46f5f2c72 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 20 Sep 2022 19:57:27 +0200 Subject: [PATCH] Fix memory leaks when parsing function calls For function calls when calling the PECallFunction() constructor a copy is made of the argument expression list. This means the original list should be deleted within the rule. Signed-off-by: Lars-Peter Clausen --- parse.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parse.y b/parse.y index a8719965d..a20a98615 100644 --- a/parse.y +++ b/parse.y @@ -3704,6 +3704,7 @@ expr_primary PECallFunction*tmp = pform_make_call_function(@1, *$1, *expr_list); delete $1; delete $2; + delete expr_list; $$ = tmp; } | class_hierarchy_identifier '(' expression_list_with_nuls ')' @@ -3711,6 +3712,7 @@ expr_primary strip_tail_items(expr_list); PECallFunction*tmp = pform_make_call_function(@1, *$1, *expr_list); delete $1; + delete expr_list; $$ = tmp; } | SYSTEM_IDENTIFIER '(' expression_list_proper ')' @@ -3718,6 +3720,7 @@ expr_primary PECallFunction*tmp = new PECallFunction(tn, *$3); FILE_NAME(tmp, @1); delete[]$1; + delete $3; $$ = tmp; } | PACKAGE_IDENTIFIER K_SCOPE_RES IDENTIFIER '(' expression_list_proper ')' @@ -3725,6 +3728,7 @@ expr_primary PECallFunction*tmp = new PECallFunction($1, use_name, *$5); FILE_NAME(tmp, @3); delete[]$3; + delete $5; $$ = tmp; } | SYSTEM_IDENTIFIER '(' ')'