Check the comments array boundry. (#993)

* check the comments array boundry

* remove empty line
This commit is contained in:
dota17 2019-09-17 01:40:09 +08:00 committed by Jordan Bayles
parent db61dba885
commit d622250c3e

View File

@ -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) {