qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

commit 422c2eebaef3a5e88af8a3c2b663530534e0e6fd
parent 8657a7e73016673a32e0b42e6f2ea6767ac6214e
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date:   Tue, 12 Apr 2016 13:06:45 -0400

avoid a few hangs in parsing code

Diffstat:
Mparse.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/parse.c b/parse.c @@ -246,7 +246,7 @@ lex() t = TTyp; goto Alpha; case '#': - while (fgetc(inf) != '\n') + while ((c=fgetc(inf)) != '\n' && c != EOF) ; case '\n': lnum++; @@ -262,6 +262,8 @@ lex() tokval.str = vnew(0, 1); for (i=0;; i++) { c = fgetc(inf); + if (c == EOF) + err("unterminated string"); vgrow(&tokval.str, i+1); if (c == '"') if (!i || tokval.str[i-1] != '\\') {