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

Unified Diff: chromeos/timezone/timezone_provider.cc

Issue 973003002: Fix crash in SimpleGeolocationProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK crash fixed. Created 5 years, 10 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 | « chromeos/geolocation/simple_geolocation_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/timezone/timezone_provider.cc
diff --git a/chromeos/timezone/timezone_provider.cc b/chromeos/timezone/timezone_provider.cc
index c9646c681bfafab199534f704a63b96b890eeffe..08e10e5359820e2b14efe859c3589f9cf00feac1 100644
--- a/chromeos/timezone/timezone_provider.cc
+++ b/chromeos/timezone/timezone_provider.cc
@@ -47,10 +47,13 @@ void TimeZoneProvider::OnTimezoneResponse(
TimeZoneRequest::TimeZoneResponseCallback callback,
scoped_ptr<TimeZoneResponseData> timezone,
bool server_error) {
- ScopedVector<TimeZoneRequest>::iterator new_end =
- std::remove(requests_.begin(), requests_.end(), request);
- DCHECK_EQ(std::distance(new_end, requests_.end()), 1);
- requests_.erase(new_end, requests_.end());
+ ScopedVector<TimeZoneRequest>::iterator position =
+ std::find(requests_.begin(), requests_.end(), request);
+ DCHECK(position != requests_.end());
+ if (position != requests_.end()) {
+ std::swap(*position, *requests_.rbegin());
+ requests_.resize(requests_.size() - 1);
+ }
callback.Run(timezone.Pass(), server_error);
}
« no previous file with comments | « chromeos/geolocation/simple_geolocation_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698