aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/util/byte_buffer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp/util/byte_buffer.cc')
-rw-r--r--src/cpp/util/byte_buffer.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cpp/util/byte_buffer.cc b/src/cpp/util/byte_buffer.cc
index 2952f94b24..3a2318d1a6 100644
--- a/src/cpp/util/byte_buffer.cc
+++ b/src/cpp/util/byte_buffer.cc
@@ -31,8 +31,8 @@
*
*/
-#include <grpc/byte_buffer_reader.h>
#include <grpc++/support/byte_buffer.h>
+#include <grpc/byte_buffer_reader.h>
namespace grpc {
@@ -84,8 +84,10 @@ ByteBuffer::ByteBuffer(const ByteBuffer& buf)
: buffer_(grpc_byte_buffer_copy(buf.buffer_)) {}
ByteBuffer& ByteBuffer::operator=(const ByteBuffer& buf) {
- Clear(); // first remove existing data
- buffer_ = grpc_byte_buffer_copy(buf.buffer_); // then copy
+ Clear(); // first remove existing data
+ if (buf.buffer_) {
+ buffer_ = grpc_byte_buffer_copy(buf.buffer_); // then copy
+ }
return *this;
}