Module: wine Branch: master Commit: e00cbef06d8df1c5aeed3bcabc3dfe660a21fa1d URL: https://gitlab.winehq.org/wine/wine/-/commit/e00cbef06d8df1c5aeed3bcabc3dfe6...
Author: Paul Gofman pgofman@codeweavers.com Date: Thu Sep 21 16:29:14 2023 -0600
ntdll: Pre-check entry->addr before taking a spin lock in RtlWaitOnAddress().
---
dlls/ntdll/sync.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index 495514a1298..efc820624bb 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -898,11 +898,14 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size
ret = NtWaitForAlertByThreadId( NULL, timeout );
- spin_lock( &queue->lock ); - /* We may have already been removed by a call to RtlWakeAddressSingle(). */ + /* We may have already been removed by a call to RtlWakeAddressSingle() or RtlWakeAddressAll(). */ if (entry.addr) - list_remove( &entry.entry ); - spin_unlock( &queue->lock ); + { + spin_lock( &queue->lock ); + if (entry.addr) + list_remove( &entry.entry ); + spin_unlock( &queue->lock ); + }
TRACE("returning %#lx\n", ret);