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

Unified Diff: chrome/utility/chrome_content_utility_client.cc

Issue 1951213002: Avoid incrementing an invalid iterator in the utility process client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« 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/utility/chrome_content_utility_client.cc
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index 8bd49b41ab339f9c7cc56db93da6ead3a4bcff82..962090ed31fada1360e247794d1534eff5776d4a 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -178,6 +178,15 @@ bool ChromeContentUtilityClient::OnMessageReceived(
for (Handlers::iterator it = handlers_.begin();
jochen (gone - plz use gerrit) 2016/05/06 10:32:30 why not: if (handled) return true; for (auto& ha
Anand Mistry (off Chromium) 2016/05/09 02:32:14 I was just trying to minimise the change. I've cha
!handled && it != handlers_.end(); ++it) {
handled = (*it)->OnMessageReceived(message);
+
+ // Warning, this is a hack! At least one of the utility process handlers
+ // adds a new handler to |handlers_| when it handles a message. This causes
+ // |it| to become invalid and hence the increment, which happens before
+ // checking the loop condition, is an invalid operation. For now, just
+ // early-out of this loop and avoid incrementing the iterator. Eventually,
+ // this will be fixed by moving everything to Mojo.
+ if (handled)
+ return true;
}
return handled;
« 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