Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76dfb047 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix use-after-free in async_manager.cc."

parents 2b620b2c de914f78
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -465,7 +465,12 @@ class AsyncManager::AsyncTaskManager {
        if (!running_) break;
        // wait until time for the next task (if any)
        if (task_queue_.size() > 0) {
          internal_cond_var_.wait_until(guard, (*task_queue_.begin())->time);
          // Make a copy of the time_point because wait_until takes a reference
          // to it and may read it after waiting, by which time the task may
          // have been freed (e.g. via CancelAsyncTask).
          std::chrono::steady_clock::time_point time =
              (*task_queue_.begin())->time;
          internal_cond_var_.wait_until(guard, time);
        } else {
          internal_cond_var_.wait(guard);
        }