summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 3343fed..ac8ef85 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -838,6 +838,13 @@ impl<'ph> PluginHandle<'ph> {
             let f: Rc<HookUd> = rc_clone_from_raw(ud as *const HookUd);
             (f)(word, ptr::null(), ptr::null()).do_eat as c_int
         }
+        // we use "Close Context" to clean up dangling pointers.
+        // hexchat lets plugins/hooks eat "Close Context" from eachother (tho
+        // not from hexchat, for good reason), so this can still be unsound
+        // if other plugins eat "Close Context". in those cases, we'd consider
+        // those plugins to be faulty, tho it'd be nice if hexchat handled it.
+        // we still do our best to be well-behaved.
+        let suppress_eat = name.eq_ignore_ascii_case("Close Context");
         let b: Rc<HookUd> = {
             let ph = self.data;
             let info = self.info;
@@ -849,7 +856,10 @@ impl<'ph> PluginHandle<'ph> {
                     call_hook_protected(ph.ph, move || {
                         let mut ph = PluginHandle::new(ph, info, contexts);
                         let word = Word::new(word);
-                        cb(&mut ph, word)
+                        match cb(&mut ph, word) {
+                            _ if suppress_eat => EAT_NONE,
+                            eat => eat,
+                        }
                     })
                 }
             }))