aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-08-08 17:51:58 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-08-08 17:52:43 -0700
commitd9d41fa898c14c3117d94f439ec5b5e23a0cadeb (patch)
tree50a3d1b5ac5dec0df5bdb48eb5bcd0772a774231 /src/objective-c
parent95a98ca768683f3864b1aefc9d6f266b22705b2a (diff)
Prevent storing in the hosts cache with a nil key
Diffstat (limited to 'src/objective-c')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index d902f95b51..e47375a866 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -57,13 +57,16 @@
// Default initializer.
- (instancetype)initWithAddress:(NSString *)address {
+ if (!address) {
+ return nil;
+ }
// To provide a default port, we try to interpret the address. If it's just a host name without
// scheme and without port, we'll use port 443. If it has a scheme, we pass it untouched to the C
// gRPC library.
// TODO(jcanizales): Add unit tests for the types of addresses we want to let pass untouched.
NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:address]];
- if (hostURL && !hostURL.port) {
+ if (hostURL.host && !hostURL.port) {
address = [hostURL.host stringByAppendingString:@":443"];
}