Skip to content

Commit

Permalink
Remove incorrect deferencing of window handles. (#367)
Browse files Browse the repository at this point in the history
Windows handles are pointer by type, but dereferencing these doesn't have any meaning and naturally may just crash.
  • Loading branch information
Wumpf authored Oct 5, 2024
1 parent 3cb5441 commit cc7267f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/os/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,12 @@ pub struct Window {
impl HasWindowHandle for Window {
fn window_handle(&self) -> std::result::Result<WindowHandle, HandleError> {
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);
Expand Down

0 comments on commit cc7267f

Please sign in to comment.