Skip to content

Commit f6d785f

Browse files
nggcdunn2001
authored andcommitted
Fix poss SEGV
for non-null terminated input.
1 parent b063cf4 commit f6d785f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib_json/json_reader.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ Reader::addComment(Location begin, Location end, CommentPlacement placement) {
401401
}
402402

403403
bool Reader::readCStyleComment() {
404-
while (current_ != end_) {
404+
while ((current_ + 1) < end_) {
405405
Char c = getNextChar();
406406
if (c == '*' && *current_ == '/')
407407
break;
@@ -520,7 +520,7 @@ bool Reader::readArray(Token& tokenStart) {
520520
currentValue().swapPayload(init);
521521
currentValue().setOffsetStart(tokenStart.start_ - begin_);
522522
skipSpaces();
523-
if (*current_ == ']') // empty array
523+
if (current_ != end_ && *current_ == ']') // empty array
524524
{
525525
Token endArray;
526526
readToken(endArray);
@@ -1361,7 +1361,7 @@ OurReader::addComment(Location begin, Location end, CommentPlacement placement)
13611361
}
13621362

13631363
bool OurReader::readCStyleComment() {
1364-
while (current_ != end_) {
1364+
while ((current_ + 1) < end_) {
13651365
Char c = getNextChar();
13661366
if (c == '*' && *current_ == '/')
13671367
break;
@@ -1503,7 +1503,7 @@ bool OurReader::readArray(Token& tokenStart) {
15031503
currentValue().swapPayload(init);
15041504
currentValue().setOffsetStart(tokenStart.start_ - begin_);
15051505
skipSpaces();
1506-
if (*current_ == ']') // empty array
1506+
if (current_ != end_ && *current_ == ']') // empty array
15071507
{
15081508
Token endArray;
15091509
readToken(endArray);

0 commit comments

Comments
 (0)