scc

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

commit 9e4dc8bf34a6c59f7073d95dc7df06d91168d833
parent 766c342d4a6d02f37a9f66c75a696530a36cdc24
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 19 Jul 2015 09:31:38 +0200

Avoid segfault in expand()

The debug fprintf in expect() was using macroname, which was
not defined in the case of symfile and symline.

Diffstat:
Mcc1/cpp.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -194,6 +194,7 @@ expand(char *begin, Symbol *sym) char *s = sym->u.s; char *arglist[NR_MACROARG], arguments[INPUTSIZ], buffer[BUFSIZE]; + macroname = sym->name; if (sym == symfile) { elen = sprintf(buffer, "\"%s\"", input->fname); goto substitute; @@ -203,7 +204,6 @@ expand(char *begin, Symbol *sym) goto substitute; } - macroname = sym->name; if (!parsepars(arguments, arglist, atoi(s))) return 0; for (n = 0; n < atoi(s); ++n)