Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4997)

Unified Diff: chrome/browser/cocoa/web_drop_target.mm

Issue 373016: Bulletproof the url going into a std::string and ensure it's not going to... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/web_drop_target.mm
===================================================================
--- chrome/browser/cocoa/web_drop_target.mm (revision 31264)
+++ chrome/browser/cocoa/web_drop_target.mm (working copy)
@@ -184,11 +184,18 @@
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]);
viettrungluu 2009/11/06 21:29:17 I'm 99.99% sure that |SysNSStringToUTF16()| chokes
+ }
+ }
}
// Given |data|, which should not be nil, fill it in using the contents of the
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698