From 801e566622141116f0ba452afef967e12f7b7089 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 19 Apr 2018 10:03:54 -0700 Subject: [PATCH] handle empty slice explicitly --- include/grpcpp/impl/codegen/call.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/grpcpp/impl/codegen/call.h b/include/grpcpp/impl/codegen/call.h index 28cc4a9e203..e324f6b14d3 100644 --- a/include/grpcpp/impl/codegen/call.h +++ b/include/grpcpp/impl/codegen/call.h @@ -573,10 +573,13 @@ class CallOpClientRecvStatus { binary_error_details = grpc::string(iter->second.begin(), iter->second.length()); } - *recv_status_ = Status(static_cast(status_code_), - grpc::string(GRPC_SLICE_START_PTR(error_message_), - GRPC_SLICE_END_PTR(error_message_)), - binary_error_details); + *recv_status_ = + Status(static_cast(status_code_), + GRPC_SLICE_IS_EMPTY(error_message_) + ? grpc::string() + : grpc::string(GRPC_SLICE_START_PTR(error_message_), + GRPC_SLICE_END_PTR(error_message_)), + binary_error_details); client_context_->set_debug_error_string( debug_error_string_ != nullptr ? debug_error_string_ : ""); g_core_codegen_interface->grpc_slice_unref(error_message_);