commit 77f45146adc228d86119395efa68aa0fb1437191 parent 249ecda69e6ec6de2dde995cc370239e9ff3e775 Author: Roberto E. Vargas Caballero <k0ga@shike2.com> Date: Sun, 31 Oct 2021 07:54:55 +0100 cc1: Add proper handling of strings too long When a string is too long we can just ignore everything until we find end of string or quotes. Diffstat:
| M | src/cmd/cc/cc1/lex.c | | | 11 | +++++++++-- |
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/cmd/cc/cc1/lex.c b/src/cmd/cc/cc1/lex.c @@ -554,8 +554,15 @@ string(void) if (c == '\\') c = escape(); if (bp == &yytext[STRINGSIZ+1]) { - /* TODO: proper error handling here */ - error("string too long"); + for (++input->p; *input->p != '"'; ++input->p) { + if (*input->p == '\\') + ++input->p; + if (*input->p == '\0') + break; + } + --bp; + errorp("string too long"); + break; } *bp++ = c; }