aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c
diff options
context:
space:
mode:
authorGravatar Michael Lumish <mlumish@google.com>2015-08-31 12:58:57 -0700
committerGravatar Michael Lumish <mlumish@google.com>2015-08-31 12:58:57 -0700
commitcb7ae77bd37f30cd6de8b22bf4253ecd5fe49f3a (patch)
treeb36c6891de9e4a3d4f8dd1a16072fdbc8f6c9f9d /src/objective-c
parent290c2bd900d531eef120a30fffde4d03de489fdf (diff)
parentd9d41fa898c14c3117d94f439ec5b5e23a0cadeb (diff)
Merge pull request #2862 from jcanizales/small-analyse-fix
Prevent using the hosts cache with a nil address
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 a7142d0f00..a8cd3a0e74 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"];
}