aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util
diff options
context:
space:
mode:
authorGravatar mike07026 <121458737@qq.com>2016-09-01 09:04:24 +0800
committerGravatar GitHub <noreply@github.com>2016-09-01 09:04:24 +0800
commite514f232a067da94e4aff31986de5de58ac73c92 (patch)
tree1524a342afc500d5caf677bf718433bdc8b9f2e2 /src/google/protobuf/util
parentb9649765f8e5c85523c138ac990a7523a54bfdbe (diff)
fix #1342 cause by ownership issues
Diffstat (limited to 'src/google/protobuf/util')
-rw-r--r--src/google/protobuf/util/internal/default_value_objectwriter.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.cc b/src/google/protobuf/util/internal/default_value_objectwriter.cc
index 1e8dab70..fa31f763 100644
--- a/src/google/protobuf/util/internal/default_value_objectwriter.cc
+++ b/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;
}