From f6d785fda89e327b99150c03af5b9a4b71b9b97c Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 25 Sep 2016 18:40:25 -0500 Subject: [PATCH] Fix poss SEGV for non-null terminated input. --- src/lib_json/json_reader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index b354be3..5e04d74 100644 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -401,7 +401,7 @@ Reader::addComment(Location begin, Location end, CommentPlacement placement) { } bool Reader::readCStyleComment() { - while (current_ != end_) { + while ((current_ + 1) < end_) { Char c = getNextChar(); if (c == '*' && *current_ == '/') break; @@ -520,7 +520,7 @@ bool Reader::readArray(Token& tokenStart) { currentValue().swapPayload(init); currentValue().setOffsetStart(tokenStart.start_ - begin_); skipSpaces(); - if (*current_ == ']') // empty array + if (current_ != end_ && *current_ == ']') // empty array { Token endArray; readToken(endArray); @@ -1361,7 +1361,7 @@ OurReader::addComment(Location begin, Location end, CommentPlacement placement) } bool OurReader::readCStyleComment() { - while (current_ != end_) { + while ((current_ + 1) < end_) { Char c = getNextChar(); if (c == '*' && *current_ == '/') break; @@ -1503,7 +1503,7 @@ bool OurReader::readArray(Token& tokenStart) { currentValue().swapPayload(init); currentValue().setOffsetStart(tokenStart.start_ - begin_); skipSpaces(); - if (*current_ == ']') // empty array + if (current_ != end_ && *current_ == ']') // empty array { Token endArray; readToken(endArray);