diff options
-rw-r--r-- | src/plugins/trigger/trigger-callback.c | 15 | ||||
-rw-r--r-- | src/plugins/trigger/trigger.c | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c index 116bb318e..04f629bf3 100644 --- a/src/plugins/trigger/trigger-callback.c +++ b/src/plugins/trigger/trigger-callback.c @@ -645,7 +645,7 @@ trigger_callback_timer_cb (void *data, int remaining_calls) struct t_trigger *trigger; struct t_hashtable *extra_vars; char str_temp[128]; - int rc; + int rc, i; time_t date; struct tm *date_tmp; @@ -654,6 +654,19 @@ trigger_callback_timer_cb (void *data, int remaining_calls) if (!trigger || trigger->hook_running) return WEECHAT_RC_OK; + /* + * remove the hook if this is the last call to timer + * (because WeeChat will remove the hook after this call, so the pointer + * will become invalid) + */ + if ((remaining_calls == 0) && trigger->hooks) + { + for (i = 0; i < trigger->hooks_count; i++) + { + trigger->hooks[i] = NULL; + } + } + trigger->hook_count_cb++; trigger->hook_running = 1; diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c index e0f6e93a8..159580535 100644 --- a/src/plugins/trigger/trigger.c +++ b/src/plugins/trigger/trigger.c @@ -414,7 +414,8 @@ trigger_unhook (struct t_trigger *trigger) { for (i = 0; i < trigger->hooks_count; i++) { - weechat_unhook (trigger->hooks[i]); + if (trigger->hooks[i]) + weechat_unhook (trigger->hooks[i]); } free (trigger->hooks); trigger->hooks = NULL; |