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

Unified Diff: chrome/browser/safe_browsing/download_protection_service.cc

Issue 12607011: Fix a crashing call to GURL::spec() in downloads_api.cc:DownloadItemToJSON() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r188056 Created 7 years, 9 months 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
Index: chrome/browser/safe_browsing/download_protection_service.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection_service.cc
index 418385009c58ed7bdb56f91a7ff857b33f315226..d12fd5e75c51ea42c9576e151071062855145538 100644
--- a/chrome/browser/safe_browsing/download_protection_service.cc
+++ b/chrome/browser/safe_browsing/download_protection_service.cc
@@ -194,9 +194,15 @@ class DownloadSBClient
for (size_t i = 0; i < url_chain_.size(); ++i) {
post_data += url_chain_[i].spec() + "\n";
}
+ // Be careful about taking the front()/back() of possibly-empty vectors!
+ // http://crbug.com/190096
+ const GURL& malicious_url = url_chain_.empty() ? GURL::EmptyGURL()
+ : url_chain_.back();
+ const GURL& page_url = url_chain_.empty() ? GURL::EmptyGURL()
+ : url_chain_.front();
ui_manager_->ReportSafeBrowsingHit(
- url_chain_.back(), // malicious_url
- url_chain_.front(), // page_url
+ malicious_url,
+ page_url,
referrer_url_,
true, // is_subresource
threat_type,

Powered by Google App Engine
This is Rietveld 408576698