diff --git a/.changes/fix-resizing-double-free.md b/.changes/fix-resizing-double-free.md new file mode 100644 index 000000000000..04c2fbafb413 --- /dev/null +++ b/.changes/fix-resizing-double-free.md @@ -0,0 +1,5 @@ +--- +"tauri-runtime-wry": "patch:bug" +--- + +Use WM_NCDESTROY instead of WM_DESTROY to free window userdata, fixing a double-free occurring in the Windows resizing handler for undecorated windows which caused STATUS_HEAP_CORRUPTION diff --git a/crates/tauri-runtime-wry/src/undecorated_resizing.rs b/crates/tauri-runtime-wry/src/undecorated_resizing.rs index 62a1d1439374..36f54f69a6d0 100644 --- a/crates/tauri-runtime-wry/src/undecorated_resizing.rs +++ b/crates/tauri-runtime-wry/src/undecorated_resizing.rs @@ -249,7 +249,7 @@ mod windows { data.has_undecorated_shadows = wparam.0 != 0; } - WM_DESTROY => { + WM_NCDESTROY => { let data = data as *mut UndecoratedResizingData; drop(Box::from_raw(data)); } @@ -388,7 +388,7 @@ mod windows { data.has_undecorated_shadows = wparam.0 != 0; } - WM_DESTROY => { + WM_NCDESTROY => { let data = GetWindowLongPtrW(child, GWLP_USERDATA); let data = data as *mut UndecoratedResizingData; drop(Box::from_raw(data));