Commit d338ac5a authored by karandeepb's avatar karandeepb Committed by Commit bot

Mac File Dialogs: Fix crash due to adding nil value to an NSMutableSet.

Crash reports beginning from Chrome V48 suggest that CreateUTIFromExtension may
return nil. This causes a crash when the uti string is added to the
NSMutableSet which holds the uti strings corresponding to the extension
dropdown. This CL does a nil check before adding the string to the set, which
should prevent the crash.

BUG=630101

Review-Url: https://codereview.chromium.org/2164223003
Cr-Commit-Position: refs/heads/master@{#407114}
parent 6ea2c758
......@@ -310,8 +310,11 @@ SelectFileDialogImpl::SetAccessoryView(
if (ext == default_extension)
default_extension_index = i;
// Crash reports suggest that CreateUTIFromExtension may return nil. Hence
// we nil check before adding to |file_type_set|. See crbug.com/630101.
base::ScopedCFTypeRef<CFStringRef> uti(CreateUTIFromExtension(ext));
[file_type_set addObject:base::mac::CFToNSCast(uti.get())];
if (uti)
[file_type_set addObject:base::mac::CFToNSCast(uti.get())];
// Always allow the extension itself, in case the UTI doesn't map
// back to the original extension correctly. This occurs with dynamic
......
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