Commit 013c962f authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Fix use-after-move in //c/b/chromeos/file_system_provider/

Fix use-after-move (potential) bugs found by the
"bugprone-use-after-move" clang-tidy check.

Bug: 1122844
Change-Id: I0f225f57e701f19705e46e5594528b5f1a82a56d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555419
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Auto-Submit: Maksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Reviewed-by: default avatarTatsuhisa Yamaguchi <yamaguchi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830489}
parent bb9d74ab
...@@ -65,15 +65,16 @@ void Queue::MaybeRun() { ...@@ -65,15 +65,16 @@ void Queue::MaybeRun() {
CHECK_GT(max_in_parallel_, executed_.size()); CHECK_GT(max_in_parallel_, executed_.size());
Task task = std::move(pending_.front()); Task task = std::move(pending_.front());
const size_t token = task.token;
pending_.pop_front(); pending_.pop_front();
auto callback = std::move(task.callback); auto callback = std::move(task.callback);
executed_[task.token] = std::move(task); executed_[token] = std::move(task);
AbortCallback abort_callback = std::move(callback).Run(); AbortCallback abort_callback = std::move(callback).Run();
// It may happen that the task is completed and removed synchronously. Hence, // It may happen that the task is completed and removed synchronously. Hence,
// we need to check if the task is still in the executed collection. // we need to check if the task is still in the executed collection.
const auto executed_task_it = executed_.find(task.token); const auto executed_task_it = executed_.find(token);
if (executed_task_it != executed_.end()) if (executed_task_it != executed_.end())
executed_task_it->second.abort_callback = std::move(abort_callback); executed_task_it->second.abort_callback = std::move(abort_callback);
} }
......
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