From: Timo Sirainen Date: Wed, 6 May 2015 12:42:31 +0000 (+0300) Subject: doveadm-server: Invalid parameters for some commands caused crash at deinit handlers. X-Git-Tag: 2.2.17.rc1~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98e8f95ffee4eacca72b1bcf082f2c735592301b;p=thirdparty%2Fdovecot%2Fcore.git doveadm-server: Invalid parameters for some commands caused crash at deinit handlers. deinit() can be called even if init() was never called. --- diff --git a/src/doveadm/doveadm-mail-mailbox-status.c b/src/doveadm/doveadm-mail-mailbox-status.c index aba6608cd1..26e029f0b0 100644 --- a/src/doveadm/doveadm-mail-mailbox-status.c +++ b/src/doveadm/doveadm-mail-mailbox-status.c @@ -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 diff --git a/src/doveadm/doveadm-mail-mailbox.c b/src/doveadm/doveadm-mail-mailbox.c index 4ea446ec85..6b4ef2b41b 100644 --- a/src/doveadm/doveadm-mail-mailbox.c +++ b/src/doveadm/doveadm-mail-mailbox.c @@ -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) diff --git a/src/doveadm/doveadm-mail.h b/src/doveadm/doveadm-mail.h index 4914a87512..a0ef6c9087 100644 --- a/src/doveadm/doveadm-mail.h +++ b/src/doveadm/doveadm-mail.h @@ -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); };