summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/web_drop_target.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa/web_drop_target.mm')
-rw-r--r--chrome/browser/cocoa/web_drop_target.mm17
1 files changed, 12 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/web_drop_target.mm b/chrome/browser/cocoa/web_drop_target.mm
index 49a4dac..f47a414 100644
--- a/chrome/browser/cocoa/web_drop_target.mm
+++ b/chrome/browser/cocoa/web_drop_target.mm
@@ -184,11 +184,18 @@ using WebKit::WebDragOperationsMask;
NSArray* titles = nil;
[pboard getURLs:&urls andTitles:&titles];
NSString* urlString = [urls objectAtIndex:0];
- NSURL* url = [NSURL URLWithString:urlString];
- if (![url scheme])
- urlString = [[NSURL fileURLWithPath:urlString] absoluteString];
- data->url = GURL([urlString UTF8String]);
- data->url_title = base::SysNSStringToUTF16([titles objectAtIndex:0]);
+ if ([urlString length]) {
+ NSURL* url = [NSURL URLWithString:urlString];
+ if (![url scheme])
+ urlString = [[NSURL fileURLWithPath:urlString] absoluteString];
+ // Check again just to make sure to not assign NULL into a std::string,
+ // which throws an exception.
+ const char* utf8Url = [urlString UTF8String];
+ if (utf8Url) {
+ data->url = GURL(utf8Url);
+ data->url_title = base::SysNSStringToUTF16([titles objectAtIndex:0]);
+ }
+ }
}
// Given |data|, which should not be nil, fill it in using the contents of the