shithub: scc

Download patch

ref: 989b26202e9264b37237371f85a19630ec4f1b0a
parent: 177b56dfc2e35ed0b5c57963c4be1d435147d0bd
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 19 02:46:41 EST 2021

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.

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