Fix a border case which causes Value::CommentInfo::setComment() to crash
authordatadiode <jochen.neubeck@vodafone.de>
Sun, 25 Jan 2015 10:01:22 +0000 (11:01 +0100)
committerChristopher Dunn <cdunn2001@gmail.com>
Sun, 25 Jan 2015 17:19:51 +0000 (11:19 -0600)
re: pull #140

src/lib_json/json_value.cpp

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