From 9e787ddc2e6d6882776b015bcd561f1e23b9c1ee Mon Sep 17 00:00:00 2001 From: lemon Date: Tue, 9 Sep 2025 17:30:42 +0200 Subject: ccomp: fix memory leak with temporary arena parsing for stmt --- c.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'c.c') diff --git a/c.c b/c.c index b09fc08..268b01c 100644 --- a/c.c +++ b/c.c @@ -2925,6 +2925,7 @@ stmt(struct comp *cm, struct function *fn) struct arena a; char mem[sizeof(struct arena) + sizeof(struct expr)*4]; } atmp = { .a.cap = sizeof(struct expr)*4 }; + struct arena *atmpp; struct expr ex; struct env e; union ref r; @@ -3110,6 +3111,7 @@ stmt(struct comp *cm, struct function *fn) struct arena *tmp = cm->exarena; cm->exarena = &atmp.a; ex = commaexpr(cm); + atmpp = cm->exarena; cm->exarena = tmp; end = newblk(fn); @@ -3124,7 +3126,7 @@ stmt(struct comp *cm, struct function *fn) useblk(fn, end); expreffects(fn, &ex); putbranch(fn, begin); - freearena(&atmp.a); + freearena(atmpp); } else if (!terminates) putbranch(fn, begin); useblk(fn, fl); } -- cgit v1.2.3