Skip to content

Commit 9b8a09a

Browse files
authored
More specific assertion for unlocking mutex not owned by the current thread (#5099)
1 parent fec1c8b commit 9b8a09a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stl/src/mutex.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ static _Thrd_result mtx_do_lock(_Mtx_t mtx, const _timespec64* target) noexcept
147147
}
148148

149149
_CRTIMP2_PURE _Thrd_result __cdecl _Mtx_unlock(_Mtx_t mtx) noexcept { // unlock mutex
150+
_THREAD_ASSERT(mtx->_Count > 0, "unlock of unowned mutex");
150151
_THREAD_ASSERT(
151-
1 <= mtx->_Count && mtx->_Thread_id == static_cast<long>(GetCurrentThreadId()), "unlock of unowned mutex");
152+
mtx->_Thread_id == static_cast<long>(GetCurrentThreadId()), "unlock of mutex not owned by the current thread");
152153

153154
if (--mtx->_Count == 0) { // leave critical section
154155
mtx->_Thread_id = -1;

0 commit comments

Comments
 (0)