diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs index 9371275..a4ef9e9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -474,6 +474,8 @@ unsafe fn call_hook_protected<F: FnOnce() -> Eat + UnwindSafe>( hexchat_print_str(ph, &s, false); } else if let Some(s) = e.downcast_ref::<Cow<'static, str>>() { hexchat_print_str(ph, &s, false); + } else { + mem::forget(e); } EAT_NONE } @@ -1725,8 +1727,9 @@ pub unsafe fn hexchat_plugin_init<'ph, T>(plugin_handle: LtPhPtr<'ph>, 1 }, r @ _ => { - if let Err(_) = r { + if let Err(e) = r { // TODO try to log panic? + mem::forget(e); } 0 }, @@ -1745,7 +1748,7 @@ pub unsafe fn hexchat_plugin_deinit<'ph, T>(plugin_handle: LtPhPtr<'ph>) -> c_in let mut info: Option<PluginInfo> = None; { let mut ausinfo = AssertUnwindSafe(&mut info); - safe_to_unload = if catch_unwind(move || { + safe_to_unload = match catch_unwind(move || { let mut userdata = pop_userdata(plugin_handle); let pluginfo = userdata.pluginfo; userdata.plug.as_mut().deinit(&mut PluginHandle::new(plugin_handle, pluginfo, Rc::clone(&userdata.contexts))); @@ -1758,7 +1761,13 @@ pub unsafe fn hexchat_plugin_deinit<'ph, T>(plugin_handle: LtPhPtr<'ph>) -> c_in // we return 0 mostly as a hint that something went // wrong, than anything else. // we do deliberately leak pluginfo on panic, also. - }).is_ok() { 1 } else { 0 }; + }) { + Ok(_) => 1, + Err(e) => { + mem::forget(e); + 0 + } + }; } if let Some(mut info) = info { info.drop_info(); |