From 437aff64992eb8a8d31360d1f9c656831b838679 Mon Sep 17 00:00:00 2001 From: lemon Date: Sun, 14 Dec 2025 21:57:07 +0100 Subject: c: fix another memory-leak-when-errors case --- c/c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'c/c.c') diff --git a/c/c.c b/c/c.c index a16bf80..7dcfa1e 100644 --- a/c/c.c +++ b/c/c.c @@ -4015,6 +4015,7 @@ stmt(struct comp *cm, struct function *fn) useblk(fn, tr); } } + atmpp = NULL; if (!match(cm, NULL, ')')) { /* iter */ /* since exarena is free'd at the end of each stmt, create a new temporary * arena to parse this expression because loop body statements would free it @@ -4037,7 +4038,6 @@ stmt(struct comp *cm, struct function *fn) useblk(fn, end); expreffects(fn, &ex); putbranch(fn, begin); - freearena(&atmpp); } else if (!terminates) putbranch(fn, begin); if (fl->npred > 0) { useblk(fn, fl); @@ -4046,6 +4046,7 @@ stmt(struct comp *cm, struct function *fn) terminates = 1; } } + if (atmpp && atmpp != cm->exarena) freearena(&atmpp); envup(cm); break; case TKWswitch: -- cgit v1.2.3