Assert argument non-null

pull/16650/head
Muxi Yan 6 years ago
parent 6a75d93e91
commit e08c05903a
  1. 6
      src/objective-c/GRPCClient/private/GRPCHost.m

@ -137,10 +137,7 @@ static NSMutableDictionary *kHostCache;
completionQueue:queue];
}
- (NSData *)nullTerminatedDataWithString:(NSString *_Nullable)string {
if (string == nil) {
return nil;
}
- (NSData *)nullTerminatedDataWithString:(NSString *)string {
// dataUsingEncoding: does not return a null-terminated string.
NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSMutableData *nullTerminated = [NSMutableData dataWithData:data];
@ -196,6 +193,7 @@ static NSMutableDictionary *kHostCache;
if (pemPrivateKey == nil && pemCertChain == nil) {
creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL, NULL);
} else {
assert(pemPrivateKey != nil && pemCertChain != nil);
grpc_ssl_pem_key_cert_pair key_cert_pair;
NSData *privateKeyASCII = [self nullTerminatedDataWithString:pemPrivateKey];
NSData *certChainASCII = [self nullTerminatedDataWithString:pemCertChain];

Loading…
Cancel
Save