Skip to content

Commit

Permalink
Check the comments array boundry. (open-source-parsers#993)
Browse files Browse the repository at this point in the history
* check the comments array boundry

* remove empty line
  • Loading branch information
dota17 authored and baylesj committed Sep 16, 2019
1 parent db61dba commit d622250
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,10 @@ void Value::Comments::set(CommentPlacement slot, String comment) {
if (!ptr_) {
ptr_ = std::unique_ptr<Array>(new Array());
}
(*ptr_)[slot] = std::move(comment);
// check comments array boundry.
if (slot < CommentPlacement::numberOfCommentPlacement) {
(*ptr_)[slot] = std::move(comment);
}
}

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

0 comments on commit d622250

Please sign in to comment.