Skip to content

Commit d622250

Browse files
dota17baylesj
authored andcommitted
Check the comments array boundry. (open-source-parsers#993)
* check the comments array boundry * remove empty line
1 parent db61dba commit d622250

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib_json/json_value.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,10 @@ void Value::Comments::set(CommentPlacement slot, String comment) {
14501450
if (!ptr_) {
14511451
ptr_ = std::unique_ptr<Array>(new Array());
14521452
}
1453-
(*ptr_)[slot] = std::move(comment);
1453+
// check comments array boundry.
1454+
if (slot < CommentPlacement::numberOfCommentPlacement) {
1455+
(*ptr_)[slot] = std::move(comment);
1456+
}
14541457
}
14551458

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

0 commit comments

Comments
 (0)