提交 7d8eddb9 编写于 作者: C Christopher Dunn 提交者: GitHub

Merge pull request #519 from open-source-parsers/fix-517

Avoid null for stringValue
......@@ -343,6 +343,7 @@ bool Value::CZString::isStaticString() const { return storage_.policy_ == noDupl
* This optimization is used in ValueInternalMap fast allocator.
*/
Value::Value(ValueType vtype) {
static char const empty[] = "";
initBasic(vtype);
switch (vtype) {
case nullValue:
......@@ -355,7 +356,8 @@ Value::Value(ValueType vtype) {
value_.real_ = 0.0;
break;
case stringValue:
value_.string_ = 0;
// allocated_ == false, so this is safe.
value_.string_ = const_cast<char*>(static_cast<char const*>(empty));
break;
case arrayValue:
case objectValue:
......
......@@ -353,7 +353,7 @@ void FastWriter::writeValue(const Value& value) {
break;
case stringValue:
{
// Is NULL possible for value.string_?
// Is NULL possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
......@@ -423,7 +423,7 @@ void StyledWriter::writeValue(const Value& value) {
break;
case stringValue:
{
// Is NULL possible for value.string_?
// Is NULL possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
......@@ -640,7 +640,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
break;
case stringValue:
{
// Is NULL possible for value.string_?
// Is NULL possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
......@@ -921,7 +921,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
break;
case stringValue:
{
// Is NULL is possible for value.string_?
// Is NULL is possible for value.string_? No.
char const* str;
char const* end;
bool ok = value.getString(&str, &end);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册