]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm-server: Invalid parameters for some commands caused crash at deinit handlers.
authorTimo Sirainen <tss@iki.fi>
Wed, 6 May 2015 12:42:31 +0000 (15:42 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 6 May 2015 12:42:31 +0000 (15:42 +0300)
deinit() can be called even if init() was never called.

src/doveadm/doveadm-mail-mailbox-status.c
src/doveadm/doveadm-mail-mailbox.c
src/doveadm/doveadm-mail.h

index aba6608cd146b09cb3b3480ae42deffe49fedf94..26e029f0b00853760a07b43c8495b98ed9a380cb 100644 (file)
@@ -214,7 +214,8 @@ static void cmd_mailbox_status_deinit(struct doveadm_mail_cmd_context *_ctx)
 {
        struct status_cmd_context *ctx = (struct status_cmd_context *)_ctx;
 
-       mail_search_args_unref(&ctx->search_args);
+       if (ctx->search_args != NULL)
+               mail_search_args_unref(&ctx->search_args);
 }
 
 static bool
index 4ea446ec85a07dd4020f7c160e5410a6286d1601..6b4ef2b41b28a00b4a581d65d39e1b7c0e1d83e8 100644 (file)
@@ -182,7 +182,8 @@ static void cmd_mailbox_list_deinit(struct doveadm_mail_cmd_context *_ctx)
 {
        struct list_cmd_context *ctx = (struct list_cmd_context *)_ctx;
 
-       mail_search_args_unref(&ctx->search_args);
+       if (ctx->search_args != NULL)
+               mail_search_args_unref(&ctx->search_args);
 }
 
 static struct doveadm_mail_cmd_context *cmd_mailbox_list_alloc(void)
index 4914a87512eb73e04d0517ec092ce439709f8f86..a0ef6c9087cbf0b2c214d4fc4897547a07d83bbf 100644 (file)
@@ -45,7 +45,8 @@ struct doveadm_mail_cmd_vfuncs {
           command. This is called once per each user. */
        int (*run)(struct doveadm_mail_cmd_context *ctx,
                   struct mail_user *mail_user);
-       /* Deinitialize the command. Called once at the end. */
+       /* Deinitialize the command. Called once at the end - even if
+          preinit() or init() was never called. */
        void (*deinit)(struct doveadm_mail_cmd_context *ctx);
 };