scc

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

commit f1e93717214682a3ed872974a92868a906290e34
parent 2559f309a589a44f99099038a6253e0e1beb66dc
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) {