From 9bea88d61611dc12eeb211e342461f9157177464 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 10 Jul 2017 22:25:11 +0200 Subject: Fix statement exprs returning a local label Like returned local variables also labels local to a statement expression can be returned, and so their symbols must not be immediately freed (though they need to be removed from the symbol table). --- tccpp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tccpp.c') diff --git a/tccpp.c b/tccpp.c index 99d3c0a..9ac98a6 100644 --- a/tccpp.c +++ b/tccpp.c @@ -1376,7 +1376,7 @@ ST_FUNC Sym *label_push(Sym **ptop, int v, int flags) /* pop labels until element last is reached. Look if any labels are undefined. Define symbols if '&&label' was used. */ -ST_FUNC void label_pop(Sym **ptop, Sym *slast) +ST_FUNC void label_pop(Sym **ptop, Sym *slast, int keep) { Sym *s, *s1; for(s = *ptop; s != slast; s = s1) { @@ -1395,9 +1395,11 @@ ST_FUNC void label_pop(Sym **ptop, Sym *slast) } /* remove label */ table_ident[s->v - TOK_IDENT]->sym_label = s->prev_tok; - sym_free(s); + if (!keep) + sym_free(s); } - *ptop = slast; + if (!keep) + *ptop = slast; } /* eval an expression for #if/#elif */ -- cgit v1.3.1