File tree 2 files changed +7
-5
lines changed 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,7 @@ bool Value::CZString::isStaticString() const { return storage_.policy_ == noDupl
343
343
* This optimization is used in ValueInternalMap fast allocator.
344
344
*/
345
345
Value::Value (ValueType vtype) {
346
+ static char const empty[] = " " ;
346
347
initBasic (vtype);
347
348
switch (vtype) {
348
349
case nullValue:
@@ -355,7 +356,8 @@ Value::Value(ValueType vtype) {
355
356
value_.real_ = 0.0 ;
356
357
break ;
357
358
case stringValue:
358
- value_.string_ = 0 ;
359
+ // allocated_ == false, so this is safe.
360
+ value_.string_ = const_cast <char *>(static_cast <char const *>(empty));
359
361
break ;
360
362
case arrayValue:
361
363
case objectValue:
Original file line number Diff line number Diff line change @@ -353,7 +353,7 @@ void FastWriter::writeValue(const Value& value) {
353
353
break ;
354
354
case stringValue:
355
355
{
356
- // Is NULL possible for value.string_?
356
+ // Is NULL possible for value.string_? No.
357
357
char const * str;
358
358
char const * end;
359
359
bool ok = value.getString (&str, &end);
@@ -423,7 +423,7 @@ void StyledWriter::writeValue(const Value& value) {
423
423
break ;
424
424
case stringValue:
425
425
{
426
- // Is NULL possible for value.string_?
426
+ // Is NULL possible for value.string_? No.
427
427
char const * str;
428
428
char const * end;
429
429
bool ok = value.getString (&str, &end);
@@ -640,7 +640,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
640
640
break ;
641
641
case stringValue:
642
642
{
643
- // Is NULL possible for value.string_?
643
+ // Is NULL possible for value.string_? No.
644
644
char const * str;
645
645
char const * end;
646
646
bool ok = value.getString (&str, &end);
@@ -921,7 +921,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
921
921
break ;
922
922
case stringValue:
923
923
{
924
- // Is NULL is possible for value.string_?
924
+ // Is NULL is possible for value.string_? No.
925
925
char const * str;
926
926
char const * end;
927
927
bool ok = value.getString (&str, &end);
You can’t perform that action at this time.
0 commit comments