scc

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

commit 4aff072f0bc195635c23adeccf0f436df02ac890
parent e34631905f3dcfacb80f3e4cd3f9dca067980c5d
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Tue, 31 Mar 2026 18:23:38 +0200

cc1: Exit when we cannot discard

If the input parameter is null then we don't have any input
that we can discard, and it just generates a segfault because
the for loop assumes that the input parameter is different
than 0, but it still checks if it can ask for more input
using the function moreinput().

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

diff --git a/src/cmd/scc-cc/cc1/lex.c b/src/cmd/scc-cc/cc1/lex.c @@ -998,6 +998,8 @@ discard(void) extern jmp_buf recover; int c; + if (!input) + exit(EXIT_FAILURE); for (c = yytoken; ; c = *input->p++) { switch (safe) { case END_COMP: