From cc7267f011fb0e36829b74e966dffca382a2b204 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Sat, 5 Oct 2024 17:32:58 +0200 Subject: [PATCH] Remove incorrect deferencing of window handles. (#367) Windows handles are pointer by type, but dereferencing these doesn't have any meaning and naturally may just crash. --- src/os/windows/mod.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/os/windows/mod.rs b/src/os/windows/mod.rs index b28ac12..ba57cbf 100644 --- a/src/os/windows/mod.rs +++ b/src/os/windows/mod.rs @@ -515,13 +515,12 @@ pub struct Window { impl HasWindowHandle for Window { fn window_handle(&self) -> std::result::Result { let raw_hwnd = self.window.unwrap(); - let hwnd = match NonZeroIsize::new(unsafe { *(raw_hwnd as *const isize) }) { + let hwnd = match NonZeroIsize::new(raw_hwnd as isize) { Some(hwnd) => hwnd, None => unimplemented!("invalid hwnd"), }; - let raw_hinstance = - unsafe { *(GetWindowLongPtrW(raw_hwnd, GWLP_HINSTANCE) as *const isize) }; + let raw_hinstance = unsafe { GetWindowLongPtrW(raw_hwnd, GWLP_HINSTANCE) }; let hinstance = NonZeroIsize::new(raw_hinstance); let mut handle = Win32WindowHandle::new(hwnd);