mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-12 10:03:51 +01: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:
parent
8386d3efe1
commit
ca21256395
@ -317,8 +317,10 @@ namespace Json {
|
||||
// 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;
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user