From d622250c3e378484b572c26b2b1db98bfc8c4c9b Mon Sep 17 00:00:00 2001 From: dota17 <50514813+dota17@users.noreply.github.com> Date: Tue, 17 Sep 2019 01:40:09 +0800 Subject: [PATCH] Check the comments array boundry. (#993) * check the comments array boundry * remove empty line --- src/lib_json/json_value.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp index 771c0dc..730794d 100644 --- a/src/lib_json/json_value.cpp +++ b/src/lib_json/json_value.cpp @@ -1450,7 +1450,10 @@ void Value::Comments::set(CommentPlacement slot, String comment) { if (!ptr_) { ptr_ = std::unique_ptr(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) {