Commit 1c9a2244 authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

Fix a crash when calculating an offset for nil string.

Calling -containsString: with nil argument throws an exception, so this
check is needed.

Bug: 880590
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Ieb3944b05fdf3573f6a552c8910025bf93312987
Reviewed-on: https://chromium-review.googlesource.com/c/1225983Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596650}
parent 844ab293
......@@ -365,7 +365,7 @@ NSString* const kOmniboxFadeAnimationKey = @"OmniboxFadeAnimation";
// default to a reasonable prefix string to give a plausible offset.
NSString* prefixString = @"https://";
if ([self.text containsString:string]) {
if (string.length > 0 && [self.text containsString:string]) {
NSRange range = [self.text rangeOfString:string];
NSRange prefixRange = NSMakeRange(0, range.location);
prefixString = [self.text substringWithRange:prefixRange];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment