Fix out-of-bounds read.
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`.
This commit is contained in:
parent
69098a18b9
commit
7168e3fd52
@ -773,7 +773,7 @@ void Reader::getLocationLineAndColumn(Location location, int& line,
|
|||||||
while (current < location && current != end_) {
|
while (current < location && current != end_) {
|
||||||
Char c = *current++;
|
Char c = *current++;
|
||||||
if (c == '\r') {
|
if (c == '\r') {
|
||||||
if (*current == '\n')
|
if (current != end_ && *current == '\n')
|
||||||
++current;
|
++current;
|
||||||
lastLineStart = current;
|
lastLineStart = current;
|
||||||
++line;
|
++line;
|
||||||
@ -1825,7 +1825,7 @@ void OurReader::getLocationLineAndColumn(Location location, int& line,
|
|||||||
while (current < location && current != end_) {
|
while (current < location && current != end_) {
|
||||||
Char c = *current++;
|
Char c = *current++;
|
||||||
if (c == '\r') {
|
if (c == '\r') {
|
||||||
if (*current == '\n')
|
if (current != end_ && *current == '\n')
|
||||||
++current;
|
++current;
|
||||||
lastLineStart = current;
|
lastLineStart = current;
|
||||||
++line;
|
++line;
|
||||||
|
Loading…
Reference in New Issue
Block a user