From 3deb0069f4861451fc174859c293ddafcad648a9 Mon Sep 17 00:00:00 2001 From: yang-g Date: Tue, 23 Jun 2015 14:06:08 -0700 Subject: [PATCH] Only copy stuff when status is ok --- src/cpp/server/server.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); }