aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2017-01-16 21:57:21 -0800
committerGravatar Muxi Yan <mxyan@google.com>2017-01-16 21:57:21 -0800
commitd3c2594883ff9aaadd387158b51fbad5dffb8624 (patch)
treec6a6392982a018329bf6c64dae51c3dee14280d5 /src/objective-c/GRPCClient/private/GRPCWrappedCall.m
parenta36bdc162a199be3f7a532734bbbbf95aa0bf1b8 (diff)
Fix test errors on string copy
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCWrappedCall.m')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index 7e73495043..43c564552b 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -215,11 +215,15 @@
__weak typeof(self) weakSelf = self;
_handler = ^{
__strong typeof(self) strongSelf = weakSelf;
- NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
- details:(char*)GRPC_SLICE_START_PTR(strongSelf->_details)];
- NSDictionary *trailers = [NSDictionary
- grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
- handler(error, trailers);
+ if (strongSelf) {
+ char *details = grpc_slice_to_c_string(strongSelf->_details);
+ NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
+ details:details];
+ NSDictionary *trailers = [NSDictionary
+ grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
+ handler(error, trailers);
+ gpr_free(details);
+ }
};
}
}