!28 【master】增加边界校验避免越界

Merge pull request !28 from fyz1019/master
This commit is contained in:
openharmony_ci
2023-01-07 12:31:20 +00:00
committed by Gitee
+8
View File
@@ -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;