diff --git a/src/lib_json/json_reader.cpp b/src/lib_json/json_reader.cpp index a921dfe456ab3b8ec40e1bded2b83b3a71f4cc92..cf3ec48b8aa62d2d52bc5c1d78f80af424e79867 100755 --- a/src/lib_json/json_reader.cpp +++ b/src/lib_json/json_reader.cpp @@ -772,6 +772,10 @@ void Reader::getLocationLineAndColumn(Location location, int& line, while (current < location && current != end_) { Char c = *current++; if (c == '\r') { + // Add boundary check to avoid cross the border + if (current == end_) { + break; + } if (*current == '\n') ++current; lastLineStart = current; @@ -1838,6 +1842,10 @@ void OurReader::getLocationLineAndColumn(Location location, int& line, while (current < location && current != end_) { Char c = *current++; if (c == '\r') { + // Add boundary check to avoid cross the border + if (current == end_) { + break; + } if (*current == '\n') ++current; lastLineStart = current;