From 3468cbaf479e3a2e9b3c7d6b00b2cb1976cce43e Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Wed, 28 Jun 2023 22:38:44 +0800 Subject: [PATCH] libexpr: fix leaking `es2` in stripIndentation (parser.y) --- src/libexpr/parser.y | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 5c9597f8a..ed6421ced 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -275,7 +275,12 @@ static Expr * stripIndentation(const PosIdx pos, SymbolTable & symbols, } /* If this is a single string, then don't do a concatenation. */ - return es2->size() == 1 && dynamic_cast((*es2)[0].second) ? (*es2)[0].second : new ExprConcatStrings(pos, true, es2); + if (es2->size() == 1 && dynamic_cast((*es2)[0].second)) { + auto *const result = (*es2)[0].second; + delete es2; + return result; + } + return new ExprConcatStrings(pos, true, es2); }