提交 e3a2be37 编写于 作者: F fangyunzhong

Add boundary check to avoid cross the border

Signed-off-by: Nfangyunzhong <fangyunzhong2@huawei.com>
上级 0f542451
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册