[hackers] [scc] [cc2-qbe] Fix writeout() without a function || Roberto E. Vargas Caballero
commit 46f4fcce1a9d9715786442d3dad0ee87d868923f
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sun Feb 12 16:51:31 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sun Feb 12 16:51:31 2017 +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; };
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 3c6f39d..d6cad6c 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -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));
Received on Sun Feb 12 2017 - 16:53:52 CET
This archive was generated by hypermail 2.3.0
: Sun Feb 12 2017 - 17:00:17 CET