From 9b846cb947f808da15fde6aa7293ba4f4f990ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 4 Feb 2024 13:57:35 +0100 Subject: [PATCH] scripts: fix crash on script unload when a hook is created in a buffer close callback (issue #2067) --- ChangeLog.adoc | 7 +++++++ src/plugins/plugin-script.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 21ff994b7..112a4cc99 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -10,6 +10,13 @@ This document lists all the changes for each version. + For a list of important changes that require manual actions, please look at release notes. +[[v4.2.2]] +== Version 4.2.2 (under dev) + +Bug fixes:: + + * scripts: fix crash on script unload when a hook is created in a buffer close callback (issue #2067) + [[v4.2.1]] == Version 4.2.1 (2024-01-22) diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c index 3ad8aec19..70c60c3ad 100644 --- a/src/plugins/plugin-script.c +++ b/src/plugins/plugin-script.c @@ -1063,6 +1063,12 @@ plugin_script_remove (struct t_weechat_plugin *weechat_plugin, plugin_script_remove_configs (weechat_plugin, script); + /* + * remove again all hooks created by this script (just in case new hooks + * were created by the calls above) + */ + weechat_unhook_all (script->name); + /* remove script from list */ if (script->prev_script) (script->prev_script)->next_script = script->next_script;