diff options
-rw-r--r-- | lr.c | 5 |
1 files changed, 4 insertions, 1 deletions
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++; |