diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 22:21:50 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 22:21:50 +0000 |
commit | 31a95b118b1fd0df09aa58638ab385f10a747873 (patch) | |
tree | b282da7703b77ee48a52d13e9c66cc0f1373f8ce /chrome/browser/cocoa/web_drop_target.mm | |
parent | f8cb42b196a29842a95ed08be1f43e6c8f0df6cb (diff) | |
download | chromium_src-31a95b118b1fd0df09aa58638ab385f10a747873.zip chromium_src-31a95b118b1fd0df09aa58638ab385f10a747873.tar.gz chromium_src-31a95b118b1fd0df09aa58638ab385f10a747873.tar.bz2 |
Bulletproof the url going into a std::string and ensure it's not going to
be NULL, which throws and exception.
BUG=26883
TEST=dragging things into the content area (urls, images, text, etc)
Review URL: http://codereview.chromium.org/373016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/web_drop_target.mm')
-rw-r--r-- | chrome/browser/cocoa/web_drop_target.mm | 17 |
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 |