]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lazy-expunge: Fix context checking
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 23 Jan 2018 08:39:30 +0000 (10:39 +0200)
committerMartti Rannanjärvi <martti.rannanjarvi@dovecot.fi>
Tue, 20 Feb 2018 12:36:20 +0000 (14:36 +0200)
Was not done properly in 462a3d92adcde4bfa9a575875bd8ae740b89ce9e

src/plugins/lazy-expunge/lazy-expunge-plugin.c

index e5032bc8bd82d4fdbe15dfd874d7be08dee65d85..989e80a1f86717162b0bab8309f58592c7d91c35 100644 (file)
        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);