Skip to content

Commit 82e2645

Browse files
authored
fix(windows): fix double free (STATUS_HEAP_CORRUPTION) of resizing handler's userdata (#13968)
* fix: double free of resizing handler's userdata on Windows Using WM_NCDESTROY instead of WM_DESTROY is more correct for freeing userdata, as windows can receive multiple WM_DESTROY events if they're parented. * chore: add change entry for resizing handler double-free fix
1 parent c134a76 commit 82e2645

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-runtime-wry": "patch:bug"
3+
---
4+
5+
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

crates/tauri-runtime-wry/src/undecorated_resizing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ mod windows {
249249
data.has_undecorated_shadows = wparam.0 != 0;
250250
}
251251

252-
WM_DESTROY => {
252+
WM_NCDESTROY => {
253253
let data = data as *mut UndecoratedResizingData;
254254
drop(Box::from_raw(data));
255255
}
@@ -388,7 +388,7 @@ mod windows {
388388
data.has_undecorated_shadows = wparam.0 != 0;
389389
}
390390

391-
WM_DESTROY => {
391+
WM_NCDESTROY => {
392392
let data = GetWindowLongPtrW(child, GWLP_USERDATA);
393393
let data = data as *mut UndecoratedResizingData;
394394
drop(Box::from_raw(data));

0 commit comments

Comments
 (0)