aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorYingchi Long <i@lyc.dev>2023-06-28 22:38:44 +0800
committerYingchi Long <i@lyc.dev>2023-06-28 22:38:44 +0800
commit3468cbaf479e3a2e9b3c7d6b00b2cb1976cce43e (patch)
tree56e9da50f86df99a11fd0cc721b3974c6b4fac10 /src/libexpr
parent60f06a1714a74bf144eb9ccad9643578248bdfc4 (diff)
libexpr: fix leaking `es2` in stripIndentation (parser.y)
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/parser.y7
1 files changed, 6 insertions, 1 deletions
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<ExprString *>((*es2)[0].second) ? (*es2)[0].second : new ExprConcatStrings(pos, true, es2);
+ if (es2->size() == 1 && dynamic_cast<ExprString *>((*es2)[0].second)) {
+ auto *const result = (*es2)[0].second;
+ delete es2;
+ return result;
+ }
+ return new ExprConcatStrings(pos, true, es2);
}