Skip to content

Commit d85acad

Browse files
committed
Swap WaitForSingleObjectEx with WaitForSingleObject and check result
1 parent 28ec93b commit d85acad

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

bindings.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ Windows.Win32.System.Threading.GetCurrentProcessId
6060
Windows.Win32.System.Threading.GetCurrentThread
6161
Windows.Win32.System.Threading.INFINITE
6262
Windows.Win32.System.Threading.ReleaseMutex
63-
Windows.Win32.System.Threading.WaitForSingleObjectEx
63+
Windows.Win32.System.Threading.WaitForSingleObject

src/dbghelp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,9 @@ pub fn init() -> Result<Init, ()> {
291291
}
292292
}
293293
debug_assert!(!lock.is_null());
294-
let r = WaitForSingleObjectEx(lock, INFINITE, FALSE);
295-
debug_assert_eq!(r, 0);
294+
if WaitForSingleObject(lock, INFINITE) != 0 {
295+
return Err(());
296+
}
296297
let ret = Init { lock };
297298

298299
// Ok, phew! Now that we're all safely synchronized, let's actually

src/windows_sys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ windows_link::link!("kernel32.dll" "system" fn RtlVirtualUnwind(handlertype : RT
4646
#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))]
4747
windows_link::link!("kernel32.dll" "system" fn RtlVirtualUnwind(handlertype : RTL_VIRTUAL_UNWIND_HANDLER_TYPE, imagebase : u64, controlpc : u64, functionentry : *const IMAGE_RUNTIME_FUNCTION_ENTRY, contextrecord : *mut CONTEXT, handlerdata : *mut *mut core::ffi::c_void, establisherframe : *mut u64, contextpointers : *mut KNONVOLATILE_CONTEXT_POINTERS) -> EXCEPTION_ROUTINE);
4848
windows_link::link!("kernel32.dll" "system" fn UnmapViewOfFile(lpbaseaddress : MEMORY_MAPPED_VIEW_ADDRESS) -> BOOL);
49-
windows_link::link!("kernel32.dll" "system" fn WaitForSingleObjectEx(hhandle : HANDLE, dwmilliseconds : u32, balertable : BOOL) -> WAIT_EVENT);
49+
windows_link::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT);
5050
windows_link::link!("kernel32.dll" "system" fn WideCharToMultiByte(codepage : u32, dwflags : u32, lpwidecharstr : PCWSTR, cchwidechar : i32, lpmultibytestr : PSTR, cbmultibyte : i32, lpdefaultchar : PCSTR, lpuseddefaultchar : *mut BOOL) -> i32);
5151
windows_link::link!("kernel32.dll" "system" fn lstrlenW(lpstring : PCWSTR) -> i32);
5252
#[repr(C)]

0 commit comments

Comments
 (0)