Skip to content

Commit

Permalink
Fix crash in SimpleGeolocationProvider.
Browse files Browse the repository at this point in the history
BUG=463150
TEST=manual

Review URL: https://codereview.chromium.org/973003002

Cr-Commit-Position: refs/heads/master@{#318866}
  • Loading branch information
alemate authored and Commit bot committed Mar 3, 2015
1 parent 3edb498 commit ae10a91
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions chromeos/geolocation/simple_geolocation_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_NE(&(*position), &(*requests_.end()));
if (position != requests_.end()) {
std::swap(*position, *requests_.rbegin());
requests_.resize(requests_.size() - 1);
}
}

} // namespace chromeos
11 changes: 7 additions & 4 deletions chromeos/timezone/timezone_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_NE(&(*position), &(*requests_.end()));
if (position != requests_.end()) {
std::swap(*position, *requests_.rbegin());
requests_.resize(requests_.size() - 1);
}

callback.Run(timezone.Pass(), server_error);
}
Expand Down

0 comments on commit ae10a91

Please sign in to comment.