aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2017-11-08 16:33:49 -0800
committerGravatar yang-g <yangg@google.com>2017-11-09 09:54:54 -0800
commitc88185900d5deb54fe02c3cdde3fc9359e185287 (patch)
tree681bf2deb411cde5f760f930bf4d247c21eccb83
parent272eebbbcd74c03dbdf66f96121115bb7f9a2f32 (diff)
handle 0 byte size message...
-rw-r--r--include/grpc++/impl/codegen/proto_utils.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h
index b5ad3d8470..799d236e0d 100644
--- a/include/grpc++/impl/codegen/proto_utils.h
+++ b/include/grpc++/impl/codegen/proto_utils.h
@@ -188,6 +188,11 @@ Status GenericSerialize(const grpc::protobuf::Message& msg,
"BufferWriter must be a subclass of io::ZeroCopyOutputStream");
*own_buffer = true;
int byte_size = msg.ByteSize();
+ if (byte_size == 0) {
+ grpc_slice empty_slice = g_core_codegen_interface->grpc_empty_slice();
+ *bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&empty_slice, 1);
+ return g_core_codegen_interface->ok();
+ }
BufferWriter writer(bp, kGrpcBufferWriterMaxBufferLength, byte_size);
return msg.SerializeToZeroCopyStream(&writer)
? g_core_codegen_interface->ok()