Commit 52c47d3d authored by alemate's avatar alemate Committed by Commit bot

Fix crash in SimpleGeolocationProvider.

BUG=463150
TEST=manual

Committed: https://crrev.com/ae10a9150af37a77ed8e9a71b19ad441d48f1cc7
Cr-Commit-Position: refs/heads/master@{#318866}

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

Cr-Commit-Position: refs/heads/master@{#318920}
parent 3e1ac1d1
......@@ -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
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment