mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-26 01:50:58 +08:00
Fix out-of-bounds read. (#1503)
getLocationLIneAndColumn would read past the end of the provided buffer if generating an error message at the end of the stream, if the final character was `\r`. Co-authored-by: Jordan Bayles <bayles.jordan@gmail.com>
This commit is contained in:
parent
0a9b9d9c6e
commit
3c2205cd97
@ -761,7 +761,7 @@ void Reader::getLocationLineAndColumn(Location location, int& line,
|
||||
while (current < location && current != end_) {
|
||||
Char c = *current++;
|
||||
if (c == '\r') {
|
||||
if (*current == '\n')
|
||||
if (current != end_ && *current == '\n')
|
||||
++current;
|
||||
lastLineStart = current;
|
||||
++line;
|
||||
@ -1801,7 +1801,7 @@ void OurReader::getLocationLineAndColumn(Location location, int& line,
|
||||
while (current < location && current != end_) {
|
||||
Char c = *current++;
|
||||
if (c == '\r') {
|
||||
if (*current == '\n')
|
||||
if (current != end_ && *current == '\n')
|
||||
++current;
|
||||
lastLineStart = current;
|
||||
++line;
|
||||
|
Loading…
x
Reference in New Issue
Block a user