diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-02-10 18:30:53 +0100 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-02-10 18:30:53 +0100 |
commit | cd7fa86f76bbcdde6bc96a238ad2db7f007fc586 (patch) | |
tree | aa33b18d7ca689f6f06a8557d21348cab85b19a2 | |
parent | 5a14865703141bcf489778960e615a9bfe2608bf (diff) | |
download | lr-cd7fa86f76bbcdde6bc96a238ad2db7f007fc586.tar.gz lr-cd7fa86f76bbcdde6bc96a238ad2db7f007fc586.tar.xz lr-cd7fa86f76bbcdde6bc96a238ad2db7f007fc586.zip |
detect and error on unterminated strings
-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++; |