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

Unified Diff: chromeos/geolocation/simple_geolocation_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 | « no previous file | chromeos/timezone/timezone_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/geolocation/simple_geolocation_provider.cc
diff --git a/chromeos/geolocation/simple_geolocation_provider.cc b/chromeos/geolocation/simple_geolocation_provider.cc
index 4a57ac7919bfac41ed4dc7a608b5b098650ff479..e083b3edb0460b911f5c2e1398bfc8f75851dd52 100644
--- a/chromeos/geolocation/simple_geolocation_provider.cc
+++ b/chromeos/geolocation/simple_geolocation_provider.cc
@@ -62,10 +62,13 @@ void SimpleGeolocationProvider::OnGeolocationResponse(
callback.Run(geoposition, server_error, elapsed);
- ScopedVector<SimpleGeolocationRequest>::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<SimpleGeolocationRequest>::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);
+ }
}
} // namespace chromeos
« no previous file with comments | « no previous file | chromeos/timezone/timezone_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698