From: Aki Tuomi Date: Tue, 23 Jan 2018 08:39:30 +0000 (+0200) Subject: lazy-expunge: Fix context checking X-Git-Tag: 2.3.9~2443 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d14fd32eff820ee5833d76abed5eca3fbdbcd640;p=thirdparty%2Fdovecot%2Fcore.git lazy-expunge: Fix context checking Was not done properly in 462a3d92adcde4bfa9a575875bd8ae740b89ce9e --- diff --git a/src/plugins/lazy-expunge/lazy-expunge-plugin.c b/src/plugins/lazy-expunge/lazy-expunge-plugin.c index e5032bc8bd..989e80a1f8 100644 --- a/src/plugins/lazy-expunge/lazy-expunge-plugin.c +++ b/src/plugins/lazy-expunge/lazy-expunge-plugin.c @@ -26,8 +26,12 @@ MODULE_CONTEXT(obj, lazy_expunge_mailbox_list_module) #define LAZY_EXPUNGE_USER_CONTEXT(obj) \ MODULE_CONTEXT(obj, lazy_expunge_mail_user_module) +#define LAZY_EXPUNGE_USER_CONTEXT_REQUIRE(obj) \ + MODULE_CONTEXT_REQUIRE(obj, lazy_expunge_mail_user_module) #define LAZY_EXPUNGE_MAIL_CONTEXT(obj) \ MODULE_CONTEXT(obj, lazy_expunge_mail_module) +#define LAZY_EXPUNGE_MAIL_CONTEXT_REQUIRE(obj) \ + MODULE_CONTEXT_REQUIRE(obj, lazy_expunge_mail_module) struct lazy_expunge_mail { union mail_module_context module_ctx; @@ -82,7 +86,7 @@ static const char * get_dest_vname(struct mailbox_list *list, struct mailbox *src_box) { struct lazy_expunge_mail_user *luser = - LAZY_EXPUNGE_USER_CONTEXT(list->ns->user); + LAZY_EXPUNGE_USER_CONTEXT_REQUIRE(list->ns->user); const char *name; char src_sep, dest_sep; @@ -282,9 +286,9 @@ static void lazy_expunge_mail_expunge(struct mail *_mail) { struct mail_namespace *ns = _mail->box->list->ns; struct lazy_expunge_mail_user *luser = - LAZY_EXPUNGE_USER_CONTEXT(ns->user); + LAZY_EXPUNGE_USER_CONTEXT_REQUIRE(ns->user); struct mail_private *mail = (struct mail_private *)_mail; - struct lazy_expunge_mail *mmail = LAZY_EXPUNGE_MAIL_CONTEXT(mail); + struct lazy_expunge_mail *mmail = LAZY_EXPUNGE_MAIL_CONTEXT_REQUIRE(mail); struct lazy_expunge_transaction *lt = LAZY_EXPUNGE_CONTEXT_REQUIRE(_mail->transaction); struct mail *real_mail; @@ -293,9 +297,6 @@ static void lazy_expunge_mail_expunge(struct mail *_mail) bool moving = mmail->moving; int ret; - i_assert(luser != NULL); - i_assert(mmail != NULL); - if (lt->delayed_error != MAIL_ERROR_NONE) return; if (mmail->recursing) { @@ -384,13 +385,11 @@ lazy_expunge_transaction_begin(struct mailbox *box, const char *reason) { struct lazy_expunge_mail_user *luser = - LAZY_EXPUNGE_USER_CONTEXT(box->list->ns->user); + LAZY_EXPUNGE_USER_CONTEXT_REQUIRE(box->list->ns->user); union mailbox_module_context *mbox = LAZY_EXPUNGE_CONTEXT_REQUIRE(box); struct mailbox_transaction_context *t; struct lazy_expunge_transaction *lt; - i_assert(luser != NULL); - t = mbox->super.transaction_begin(box, flags, reason); lt = i_new(struct lazy_expunge_transaction, 1); lt->copy_only_last_instance = luser->copy_only_last_instance; @@ -572,9 +571,8 @@ lazy_expunge_mail_namespaces_created(struct mail_namespace *namespaces) static void lazy_expunge_user_deinit(struct mail_user *user) { - struct lazy_expunge_mail_user *luser = LAZY_EXPUNGE_USER_CONTEXT(user); + struct lazy_expunge_mail_user *luser = LAZY_EXPUNGE_USER_CONTEXT_REQUIRE(user); - i_assert(luser != NULL); /* mail_namespaces_created hook isn't necessarily ever called */ if (luser->lazy_ns != NULL) mail_namespace_unref(&luser->lazy_ns);