mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-14 23:07:55 +02:00
setComment() will assert if comment does not start with / (or if it were NULL, which would have seg-faulted before).
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include <iostream>
|
||||
#include <json/value.h>
|
||||
#include <json/writer.h>
|
||||
#include <utility>
|
||||
@@ -149,6 +150,9 @@ Value::CommentInfo::setComment( const char *text )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user