Fix race condition with use-after-free in TimerManager.

This commit is contained in:
Christian Speckner 2024-08-11 11:31:43 +02:00
parent 93fd9a2e2b
commit e7c72a3532
1 changed files with 5 additions and 2 deletions

View File

@ -179,8 +179,11 @@ void TimerManager::timerThreadWorker()
} }
else else
{ {
// Wait until the timer is ready or a timer creation notifies // Wait until the timer is ready or a timer creation notifies. Note that wait until accesses
wakeUp.wait_until(lock, timer.next); // time_point by reference, so we make a copy in case the current time is deleted while the
// thread sleeps.
const auto next = timer.next;
wakeUp.wait_until(lock, next);
} }
} }
} }