]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
notify: Change notify_unregister() to zero the pointer, and ignore NULL
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 5 Apr 2023 18:27:51 +0000 (21:27 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 7 Apr 2023 18:44:00 +0000 (18:44 +0000)
src/plugins/mail-log/mail-log-plugin.c
src/plugins/notify-status/notify-status-plugin.c
src/plugins/notify/notify-plugin.c
src/plugins/notify/notify-plugin.h
src/plugins/push-notification/push-notification-plugin.c
src/plugins/replication/replication-plugin.c

index 58aff34ce5b24f033900ad955e3478c749c5c8d9..824c81c1c22361d62ababedbfc5116da23997b26 100644 (file)
@@ -544,7 +544,7 @@ void mail_log_plugin_init(struct module *module)
 void mail_log_plugin_deinit(void)
 {
        mail_storage_hooks_remove(&mail_log_mail_storage_hooks);
-       notify_unregister(mail_log_ctx);
+       notify_unregister(&mail_log_ctx);
 }
 
 const char *mail_log_plugin_dependencies[] = { "notify", NULL };
index 874fdee2fad5370d421a11c099a8fea27dee6f45..c537c3b7031700e389bf2b7aec51e118b793ce77 100644 (file)
@@ -295,8 +295,7 @@ static void notify_status_mail_user_deinit(struct mail_user *user)
 
        dict_wait(nuser->dict);
        dict_deinit(&nuser->dict);
-       if (nuser->context != NULL)
-               notify_unregister(nuser->context);
+       notify_unregister(&nuser->context);
        nuser->module_ctx.super.deinit(user);
 }
 
index d7aec8c7e814ac799e7a517d28bfe995dd8f44b9..929dcbffbc08c8613678c51a1795fdac93e09a72 100644 (file)
@@ -239,8 +239,14 @@ notify_register(const struct notify_vfuncs *v)
        return ctx;
 }
 
-void notify_unregister(struct notify_context *ctx)
+void notify_unregister(struct notify_context **_ctx)
 {
+       struct notify_context *ctx = *_ctx;
+
+       if (ctx == NULL)
+               return;
+       *_ctx = NULL;
+
        struct notify_mail_txn *mail_txn = ctx->mail_txn_list;
 
        for (; mail_txn != NULL; mail_txn = mail_txn->next) {
index 3c95071f6be45c226ccf6ad5581917c4d09c4324..f2a8f76391be5017391c30eaf9e111b4567389c0 100644 (file)
@@ -35,7 +35,7 @@ struct notify_vfuncs {
 
 struct notify_context *
 notify_register(const struct notify_vfuncs *vfuncs);
-void notify_unregister(struct notify_context *ctx);
+void notify_unregister(struct notify_context **ctx);
 
 void notify_plugin_init(struct module *module);
 void notify_plugin_deinit(void);
index 23c7e980dfdd6b34fd0407236d3cea1cec206dcc..75fcfc7f77c233c7997e12c0d4d08cb0d5028887 100644 (file)
@@ -378,5 +378,5 @@ void push_notification_plugin_deinit(void)
 
        push_notification_event_unregister_rfc5423_events();
        mail_storage_hooks_remove(&push_notification_storage_hooks);
-       notify_unregister(push_notification_ctx);
+       notify_unregister(&push_notification_ctx);
 }
index ad55974cc63e4d63854da257c53c7df334f0d4e4..e846e52fbc0d3b36feed5ecff693169de2b18569 100644 (file)
@@ -419,7 +419,7 @@ void replication_plugin_deinit(void)
        i_free_and_null(fifo_path);
 
        mail_storage_hooks_remove(&replication_mail_storage_hooks);
-       notify_unregister(replication_ctx);
+       notify_unregister(&replication_ctx);
 }
 
 const char *replication_plugin_dependencies[] = { "notify", NULL };