From cd7fa86f76bbcdde6bc96a238ad2db7f007fc586 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Wed, 10 Feb 2016 18:30:53 +0100 Subject: detect and error on unterminated strings --- lr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lr.c') diff --git a/lr.c b/lr.c index c819491..a90b786 100644 --- a/lr.c +++ b/lr.c @@ -376,7 +376,8 @@ parse_string(char **s) if (*pos == '"') { pos++; - while (*pos != '"' || (*pos == '"' && *(pos+1) == '"')) { + while (*pos && + (*pos != '"' || (*pos == '"' && *(pos+1) == '"'))) { if (len >= bufsiz) { bufsiz = 2*bufsiz + 16; buf = realloc(buf, bufsiz); @@ -387,6 +388,8 @@ parse_string(char **s) pos++; buf[len++] = *pos++; } + if (!*pos) + parse_error("unterminated string"); if (buf) buf[len] = 0; pos++; -- cgit 1.4.1