scc

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

commit 5510ac1ca190a4bacb6330ca37a7ab5f0b347225
parent 98caf6b9f86aa7e0af46d9de891e467364be6d2d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 21 Aug 2015 13:01:52 +0200

Don't search in the argument array when there is no arguments

This error was causing an invalid access to args array, because
nargs could be -1, and the fallback condition to print again
the token was failling due to it.

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

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -285,7 +285,7 @@ getdefs(Symbol *args[NR_MACROARG], int nargs, char *bp, size_t bufsiz) for (;;) { ispar = 0; - if (yytoken == IDEN) { + if (yytoken == IDEN && nargs >= 0) { for (argp = args; argp < &args[nargs]; ++argp) { if (*argp == yylval.sym) break;