aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/io/coded_stream_inl.h
diff options
context:
space:
mode:
authorGravatar xiaofeng@google.com <xiaofeng@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2013-02-25 10:24:11 +0000
committerGravatar xiaofeng@google.com <xiaofeng@google.com@630680e5-0e50-0410-840e-4b1c322b438d>2013-02-25 10:24:11 +0000
commitde3494fe5cbfdb75631bd07877341d56d721730c (patch)
tree7aa02a8aa3c80784ea17a21722ab93bb09cdbabb /src/google/protobuf/io/coded_stream_inl.h
parente406747cd50270855c75902bb3a6de2e7659763d (diff)
Fix issue 403, issue 456, issue 462
Diffstat (limited to 'src/google/protobuf/io/coded_stream_inl.h')
-rw-r--r--src/google/protobuf/io/coded_stream_inl.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/google/protobuf/io/coded_stream_inl.h b/src/google/protobuf/io/coded_stream_inl.h
index 94495fb8..144f44f0 100644
--- a/src/google/protobuf/io/coded_stream_inl.h
+++ b/src/google/protobuf/io/coded_stream_inl.h
@@ -50,8 +50,12 @@ inline bool CodedInputStream::InternalReadStringInline(string* buffer,
if (BufferSize() >= size) {
STLStringResizeUninitialized(buffer, size);
- memcpy(string_as_array(buffer), buffer_, size);
- Advance(size);
+ // When buffer is empty, string_as_array(buffer) will return NULL but memcpy
+ // requires non-NULL pointers even when size is 0. Hench this check.
+ if (size > 0) {
+ memcpy(string_as_array(buffer), buffer_, size);
+ Advance(size);
+ }
return true;
}