setComment() will assert if comment does not start with / (or if it were NULL, which would have seg-faulted before).
diff --git a/include/json/value.h b/include/json/value.h
index fe2f9eb..19e2966 100644
--- a/include/json/value.h
+++ b/include/json/value.h
@@ -317,8 +317,10 @@
// EnumValues enumValues() const;
//# endif
+ /// Comments must be //... or /* ... */
void setComment( const char *comment,
CommentPlacement placement );
+ /// Comments must be //... or /* ... */
void setComment( const std::string &comment,
CommentPlacement placement );
bool hasComment( CommentPlacement placement ) const;
diff --git a/src/lib_json/json_value.cpp b/src/lib_json/json_value.cpp
index b3e90b6..0fb735f 100644
--- a/src/lib_json/json_value.cpp
+++ b/src/lib_json/json_value.cpp
@@ -1,3 +1,4 @@
+#include <iostream>
#include <json/value.h>
#include <json/writer.h>
#include <utility>
@@ -149,6 +150,9 @@
{
if ( comment_ )
valueAllocator()->releaseStringValue( comment_ );
+ JSON_ASSERT( text );
+ JSON_ASSERT_MESSAGE( text[0]==NULL || text[0]=='/', "Comments must start with /");
+ // It seems that /**/ style comments are acceptable as well.
comment_ = valueAllocator()->duplicateStringValue( text );
}