Skip to content

Commit 75df789

Browse files
committed
check the comments array boundry
1 parent 12325b8 commit 75df789

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib_json/json_value.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,11 @@ void Value::Comments::set(CommentPlacement slot, String comment) {
14671467
if (!ptr_) {
14681468
ptr_ = std::unique_ptr<Array>(new Array());
14691469
}
1470-
(*ptr_)[slot] = std::move(comment);
1470+
// check comments array boundry.
1471+
if (slot < CommentPlacement::numberOfCommentPlacement) {
1472+
(*ptr_)[slot] = std::move(comment);
1473+
}
1474+
14711475
}
14721476

14731477
void Value::setComment(String comment, CommentPlacement placement) {

0 commit comments

Comments
 (0)