From 94bf58735d06eb3d43dcd9a93232f18d0d8d4acc Mon Sep 17 00:00:00 2001 From: "Denny C. Dai" Date: Tue, 7 Sep 2021 09:32:48 -0700 Subject: [PATCH] [gRPC ObjC] Adding strong self nullability check (#27236) --- .../GRPCClient/private/GRPCCore/GRPCWrappedCall.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m index 7d7e77f6ba0..cf3b036ddf9 100644 --- a/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCCore/GRPCWrappedCall.m @@ -143,9 +143,11 @@ __weak typeof(self) weakSelf = self; _handler = ^{ __strong typeof(self) strongSelf = weakSelf; - NSDictionary *metadata = - [NSDictionary grpc_dictionaryFromMetadataArray:strongSelf->_headers]; - handler(metadata); + if (strongSelf) { + NSDictionary *metadata = + [NSDictionary grpc_dictionaryFromMetadataArray:strongSelf->_headers]; + handler(metadata); + } }; } } @@ -175,7 +177,9 @@ __weak typeof(self) weakSelf = self; _handler = ^{ __strong typeof(self) strongSelf = weakSelf; - handler(strongSelf->_receivedMessage); + if (strongSelf) { + handler(strongSelf->_receivedMessage); + } }; } }