mirror of
https://gitee.com/openharmony/third_party_jsoncpp
synced 2025-02-21 11:22:33 +00:00
Add boundary check to avoid cross the border
Signed-off-by: fangyunzhong <fangyunzhong2@huawei.com>
This commit is contained in:
parent
0f54245188
commit
e3a2be3767
@ -772,6 +772,10 @@ 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') {
|
||||||
|
// Add boundary check to avoid cross the border
|
||||||
|
if (current == end_) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (*current == '\n')
|
if (*current == '\n')
|
||||||
++current;
|
++current;
|
||||||
lastLineStart = current;
|
lastLineStart = current;
|
||||||
@ -1838,6 +1842,10 @@ 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') {
|
||||||
|
// Add boundary check to avoid cross the border
|
||||||
|
if (current == end_) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (*current == '\n')
|
if (*current == '\n')
|
||||||
++current;
|
++current;
|
||||||
lastLineStart = current;
|
lastLineStart = current;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user