From f07d80c2400e1d51b1978f435358c4d039145639 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Mon, 6 Jan 2025 21:43:11 +0000 Subject: [PATCH] Fix provenance in direct32 sample Using transmute creates a pointer without provenance. Using an `as` cast instead fixes this. --- crates/samples/windows/direct3d12/src/main.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/samples/windows/direct3d12/src/main.rs b/crates/samples/windows/direct3d12/src/main.rs index 11586f77f6..0dbb7aea79 100644 --- a/crates/samples/windows/direct3d12/src/main.rs +++ b/crates/samples/windows/direct3d12/src/main.rs @@ -5,8 +5,6 @@ use windows::{ Win32::UI::WindowsAndMessaging::*, }; -use std::mem::transmute; - trait DXSample { fn new(command_line: &SampleCommandLine) -> Result where @@ -151,7 +149,7 @@ extern "system" fn wndproc( match message { WM_CREATE => { unsafe { - let create_struct: &CREATESTRUCTA = transmute(lparam); + let create_struct: &CREATESTRUCTA = &*(lparam.0 as *const CREATESTRUCTA); SetWindowLongPtrA(window, GWLP_USERDATA, create_struct.lpCreateParams as _); } LRESULT::default()