scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 46f4fcce1a9d9715786442d3dad0ee87d868923f
parent 17417c34fe371e2ce8ea7a5acad5d39ff77dca0f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 12 Feb 2017 16:51:31 +0100

[cc2-qbe] Fix writeout() without a function

Writeout() uses the curfun pointer without checking
if we have a function. This generates a segmentation
fault in this input:

	struct S { unsigned int a; };

Diffstat:
Mcc2/arch/qbe/code.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c @@ -340,6 +340,8 @@ writeout(void) char *sep, *name; int haslabel = 0; + if (!curfun) + return; if (curfun->kind == SGLOB) fputs("export ", stdout); printf("function %s %s(", size2stack(&curfun->rtype), symname(curfun));