Skip to content

Commit 0e4555a

Browse files
Merge pull request #195 from loss-and-quick/fix/windows-resume-unsafe-block
fix(desktop): wrap raw-pointer deref in unsafe block (edition 2024)
2 parents 392649c + db8c066 commit 0e4555a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src-tauri/src/desktop/windows/resume.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ unsafe extern "system" fn on_power_event(
3232
if (event_type == PBT_APMRESUMEAUTOMATIC || event_type == PBT_APMRESUMESUSPEND)
3333
&& !context.is_null()
3434
{
35-
let tx = &*(context as *const mpsc::Sender<()>);
35+
// SAFETY: `context` is the `Context` pointer we registered — a `Box`ed
36+
// `mpsc::Sender<()>` that `run_watcher` keeps alive for the process lifetime
37+
// (it parks holding `tx` and never unregisters), so the reference is valid.
38+
// Non-null checked above. Edition 2024 requires the explicit block even in an
39+
// `unsafe fn`.
40+
let tx = unsafe { &*(context as *const mpsc::Sender<()>) };
3641
let _ = tx.try_send(());
3742
}
3843
0 // NO_ERROR

0 commit comments

Comments
 (0)