fix #1342 cause by ownership issues

pull/2045/head
mike07026 8 years ago committed by GitHub
parent b9649765f8
commit e514f232a0
  1. 5
      src/google/protobuf/util/internal/default_value_objectwriter.cc

@ -165,7 +165,10 @@ DefaultValueObjectWriter* DefaultValueObjectWriter::RenderBytes(
if (current_ == NULL) {
ow_->RenderBytes(name, value);
} else {
RenderDataPiece(name, DataPiece(value, false, true));
// Since StringPiece is essentially a pointer, takes a copy of "value" to
// avoid ownership issues.
string_values_.push_back(new string(value.ToString()));
RenderDataPiece(name, DataPiece(*string_values_.back(), false, true));
}
return this;
}

Loading…
Cancel
Save