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

Loading…
Cancel
Save