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

Unified Diff: chrome/browser/extensions/extension_webrequest_api_helpers.cc

Issue 8894003: Fix crasher if onBeforeSendHeaders contains no new headers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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/extensions/extension_webrequest_api_helpers.cc
diff --git a/chrome/browser/extensions/extension_webrequest_api_helpers.cc b/chrome/browser/extensions/extension_webrequest_api_helpers.cc
index 9819185dc478a5e54cf2d1df8d6a0f03a90aa615..87cc29578503fc16ca3e61e4cd83bb17597f0264 100644
--- a/chrome/browser/extensions/extension_webrequest_api_helpers.cc
+++ b/chrome/browser/extensions/extension_webrequest_api_helpers.cc
@@ -140,23 +140,27 @@ EventResponseDelta* CalculateOnBeforeSendHeadersDelta(
new EventResponseDelta(extension_id, extension_install_time);
result->cancel = cancel;
- // Find deleted headers.
- {
- net::HttpRequestHeaders::Iterator i(*old_headers);
- while (i.GetNext()) {
- if (!new_headers->HasHeader(i.name())) {
- result->deleted_request_headers.push_back(i.name());
+ // The event listener might not have passed any new headers if he
+ // just wanted to cancel the request.
+ if (new_headers) {
+ // Find deleted headers.
+ {
+ net::HttpRequestHeaders::Iterator i(*old_headers);
+ while (i.GetNext()) {
+ if (!new_headers->HasHeader(i.name())) {
+ result->deleted_request_headers.push_back(i.name());
+ }
}
}
- }
- // Find modified headers.
- {
- net::HttpRequestHeaders::Iterator i(*new_headers);
- while (i.GetNext()) {
- std::string value;
- if (!old_headers->GetHeader(i.name(), &value) || i.value() != value) {
- result->modified_request_headers.SetHeader(i.name(), i.value());
+ // Find modified headers.
+ {
+ net::HttpRequestHeaders::Iterator i(*new_headers);
+ while (i.GetNext()) {
+ std::string value;
+ if (!old_headers->GetHeader(i.name(), &value) || i.value() != value) {
+ result->modified_request_headers.SetHeader(i.name(), i.value());
+ }
}
}
}
« 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