aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/json_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/util/json_util.cc')
-rw-r--r--src/google/protobuf/util/json_util.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/google/protobuf/util/json_util.cc b/src/google/protobuf/util/json_util.cc
index c85f1899..ce3569ce 100644
--- a/src/google/protobuf/util/json_util.cc
+++ b/src/google/protobuf/util/json_util.cc
@@ -61,9 +61,11 @@ void ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) {
buffer_size_ -= len;
return;
}
- memcpy(buffer_, bytes, buffer_size_);
- bytes += buffer_size_;
- len -= buffer_size_;
+ if (buffer_size_ > 0) {
+ memcpy(buffer_, bytes, buffer_size_);
+ bytes += buffer_size_;
+ len -= buffer_size_;
+ }
if (!stream_->Next(&buffer_, &buffer_size_)) {
// There isn't a way for ByteSink to report errors.
buffer_size_ = 0;