scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 989b26202e9264b37237371f85a19630ec4f1b0a
parent 177b56dfc2e35ed0b5c57963c4be1d435147d0bd
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 19 Nov 2021 07:46:41 +0100

cc1: Check for input validity in discard()

When discard() is called we cannot ensure the correctness of the
input pointer, because if an eof is found then the input pointer
is freed.

Diffstat:
Msrc/cmd/cc/cc1/lex.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/cmd/cc/cc1/lex.c b/src/cmd/cc/cc1/lex.c @@ -816,6 +816,9 @@ discard(void) extern jmp_buf recover; int c; + if (!input) + return; + input->begin = input->p; for (c = yytoken; ; c = *input->begin++) { switch (safe) {