diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-11-19 16:18:19 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-11-19 16:18:38 +0100 |
commit | ce612f17506345527382ec70d6dc398ebe94dbb1 (patch) | |
tree | 8f09f5be1583b18cdfbee7e54f9ea9ec1e2a8a72 | |
parent | 9346f8429957e356d21c665bab59fe45bcf1f74e (diff) | |
parent | 12519bf62b8c49b1c1744eca6ea5b3162a61f962 (diff) |
Merge #9186: test: Fix use-after-free in scheduler tests
12519bf test: Fix use-after-free in scheduler tests (Wladimir J. van der Laan)
-rw-r--r-- | src/scheduler.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 52777b61f9..27c03f154c 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -54,9 +54,10 @@ void CScheduler::serviceQueue() #else // Some boost versions have a conflicting overload of wait_until that returns void. // Explicitly use a template here to avoid hitting that overload. - while (!shouldStop() && !taskQueue.empty() && - newTaskScheduled.wait_until<>(lock, taskQueue.begin()->first) != boost::cv_status::timeout) { - // Keep waiting until timeout + while (!shouldStop() && !taskQueue.empty()) { + boost::chrono::system_clock::time_point timeToWaitFor = taskQueue.begin()->first; + if (newTaskScheduled.wait_until<>(lock, timeToWaitFor) == boost::cv_status::timeout) + break; // Exit loop after timeout, it means we reached the time of the event } #endif // If there are multiple threads, the queue can empty while we're waiting (another |