Fix a border case which causes Value::CommentInfo::setComment() to crash

re: pull #140
This commit is contained in:
datadiode 2015-01-25 11:01:22 +01:00 committed by Christopher Dunn
parent dd91914b1b
commit 2f046b584d

View File

@ -142,8 +142,10 @@ Value::CommentInfo::~CommentInfo() {
} }
void Value::CommentInfo::setComment(const char* text) { void Value::CommentInfo::setComment(const char* text) {
if (comment_) if (comment_) {
releaseStringValue(comment_); releaseStringValue(comment_);
comment_ = 0;
}
JSON_ASSERT(text != 0); JSON_ASSERT(text != 0);
JSON_ASSERT_MESSAGE( JSON_ASSERT_MESSAGE(
text[0] == '\0' || text[0] == '/', text[0] == '\0' || text[0] == '/',