summary refs log tree commit diff
path: root/parse.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-12 13:06:45 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-12 13:06:45 -0400
commit422c2eebaef3a5e88af8a3c2b663530534e0e6fd (patch)
tree66bc30b3b53ad7423c07455465fbc8432d7cb4c4 /parse.c
parent8657a7e73016673a32e0b42e6f2ea6767ac6214e (diff)
downloadroux-422c2eebaef3a5e88af8a3c2b663530534e0e6fd.tar.gz
avoid a few hangs in parsing code
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 37e387a..07b35e9 100644
--- 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] != '\\') {