diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2019-04-21 12:03:31 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2019-04-21 12:03:31 -0300 |
commit | b4d9f1aa07f229a29ae518bf67721acc92ee43ad (patch) | |
tree | 6d76bf43c8c7a2d3b827820a965964ad581277aa | |
parent | 100119003abc9f0c6f4cec5d53c1444f0674a1e3 (diff) |
Fix Context issue
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs index ac34340..444753e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1272,8 +1272,12 @@ unsafe fn wrap_context(ph: &mut PluginHandle, ctx: *const internals::HexchatCont let hook = std::panic::AssertUnwindSafe(Rc::downgrade(&closure)); // dropping the Context should drop the Closure ph.skip_pri_ck = true; closure.set(Some(ph.hook_print("Close Context", move |ph, _| { - let _ = &ctxp; - let _: Option<PrintHookHandle> = hook.upgrade().unwrap().replace(None); + // need to be careful not to recurse or leak memory + let ph = ph.ph; + let ctx = ((*ph).hexchat_get_context)(ph); + if **ctxp == ctx { + let _: Option<PrintHookHandle> = hook.upgrade().unwrap().replace(None); + } EAT_NONE }, libc::c_int::min_value()))); ph.skip_pri_ck = false; |