Skip to content

Commit

Permalink
Always forget panic payload
Browse files Browse the repository at this point in the history
  • Loading branch information
MolotovCherry committed Feb 2, 2025
1 parent 6a2da63 commit 1357e8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions crates/loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod utils;

use std::{
ffi::c_void,
panic,
mem, panic,
sync::{LazyLock, Mutex, Once, OnceLock},
thread,
};
Expand Down Expand Up @@ -139,8 +139,12 @@ unsafe extern "system-unwind" fn Init(data: &ThreadData) -> u32 {

// If there was no panic, but error was bubbled up, then log the error
// Panic is already logged in the hook, so we can ignore that
if let Ok(Err(e)) = result {
error!("{e}");
match result {
Ok(Ok(_)) => (),
Ok(Err(e)) => error!("{e}"),
// the payload may panic, so forget it
// also, custom panic hook already handled this
Err(e) => mem::forget(e),
}

0
Expand Down
6 changes: 5 additions & 1 deletion crates/yabg3nml/src/wapi/enum_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ extern "system" fn enum_cb(param0: HWND, _: LPARAM) -> BOOL {
}

// panic
Err(_) => false.into(),
Err(e) => {
// so it never panics
mem::forget(e);
false.into()
}
}
}

0 comments on commit 1357e8e

Please sign in to comment.