shithub: scc

Download patch

ref: 9e4dc8bf34a6c59f7073d95dc7df06d91168d833
parent: 766c342d4a6d02f37a9f66c75a696530a36cdc24
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Jul 19 05:31:38 EDT 2015

Avoid segfault in expand()

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

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -194,6 +194,7 @@
 	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 @@
 		goto substitute;
 	}
 
-	macroname = sym->name;
 	if (!parsepars(arguments, arglist, atoi(s)))
 		return 0;
 	for (n = 0; n < atoi(s); ++n)