aboutsummaryrefslogtreecommitdiffhomepage
path: root/c/c.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-14 21:57:07 +0100
committerlemon <lsof@mailbox.org>2025-12-14 21:57:07 +0100
commit437aff64992eb8a8d31360d1f9c656831b838679 (patch)
treefcfe220eddd63189f253f3810b1f9166598f4e0b /c/c.c
parent450869ce81b72c7380b4c83149fb39f9f66f28dc (diff)
c: fix another memory-leak-when-errors case
Diffstat (limited to 'c/c.c')
-rw-r--r--c/c.c3
1 files changed, 2 insertions, 1 deletions
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: