From e8a655d99bd153c03324f3e553add7a3e1659839 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Fri, 1 May 2020 13:06:07 +0200 Subject: [PATCH] fix race condition in cResetEvent::Wait(u32) --- core/stdclass.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/stdclass.cpp b/core/stdclass.cpp index 52af52000..713591228 100644 --- a/core/stdclass.cpp +++ b/core/stdclass.cpp @@ -195,14 +195,12 @@ void cResetEvent::Reset() bool cResetEvent::Wait(u32 msec) { - bool rc = true; + std::unique_lock lock(mutx); - std::unique_lock lock(mutx); - - if (!state) { - rc = (cond.wait_for(lock, std::chrono::milliseconds(msec)) == std::cv_status::no_timeout); - } + if (!state) + cond.wait_for(lock, std::chrono::milliseconds(msec)); + bool rc = state; state = false; return rc;