From b07d9bd417207e7cf9ff310f4195e4a56f04044e Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Wed, 8 Jul 2026 16:50:12 -0400 Subject: [PATCH] auto_update_helper: Use optional reference for dialog state --- crates/auto_update_helper/src/dialog.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/auto_update_helper/src/dialog.rs b/crates/auto_update_helper/src/dialog.rs index 81ef1c588d1..2625b3171d3 100644 --- a/crates/auto_update_helper/src/dialog.rs +++ b/crates/auto_update_helper/src/dialog.rs @@ -237,12 +237,10 @@ where // procedure can re-enter (for instance through the modal loop that `show_error` runs), and // re-`Box::from_raw`-ing the same pointer would create a second owner aliasing a live // allocation. The pointer is null before `WM_NCCREATE` stores it and after `WM_NCDESTROY` - // clears it, so guard against dereferencing null. + // clears it; `as_ref` turns that null case into `None` instead of dereferencing it. let raw = unsafe { GetWindowLongPtrW(hwnd, GWLP_USERDATA) as *const RefCell }; - if raw.is_null() { - return None; - } - Some(f(unsafe { &*raw })) + let data = unsafe { raw.as_ref() }; + data.map(f) } fn get_system_ui_font_name() -> String {