diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 31b6a0ee004..4c44d9ec506 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -368,10 +368,12 @@ Server::GenericAsyncRequest::GenericAsyncRequest( bool Server::GenericAsyncRequest::FinalizeResult(void** tag, bool* status) { // TODO(yangg) remove the copy here. - static_cast(context_)->method_ = call_details_.method; - static_cast(context_)->host_ = call_details_.host; - gpr_free(call_details_.method); - gpr_free(call_details_.host); + if (*status) { + static_cast(context_)->method_ = call_details_.method; + static_cast(context_)->host_ = call_details_.host; + gpr_free(call_details_.method); + gpr_free(call_details_.host); + } return BaseAsyncRequest::FinalizeResult(tag, status); }