]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: Fixed crash caused by pool_unref() API change.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 25 Apr 2016 09:07:25 +0000 (12:07 +0300)
committerGitLab <gitlab@git.dovecot.net>
Mon, 25 Apr 2016 12:20:07 +0000 (15:20 +0300)
Calling pool_unref() set the mail_private->pool=NULL, which crashed in
index_mail_free(). Fixed this by removing the unnecessary ref/unref
entirely. We're already waiting in imapc_mail_close() for all the
existing FETCHes to finish, so the callback will always have only
valid mails with valid pools.

src/lib-storage/index/imapc/imapc-mail-fetch.c
src/lib-storage/index/imapc/imapc-mail.c

index 6a0348285df15dc212fdfcce884bb24e88608c17..36a7bb255d272b12ca7869fac037f41edc872fb9 100644 (file)
@@ -67,7 +67,6 @@ imapc_mail_fetch_callback(const struct imapc_command_reply *reply,
                imapc_mail_set_failure(mail, reply);
                if (--mail->fetch_count == 0)
                        mail->fetching_fields = 0;
-               pool_unref(&mail->imail.mail.pool);
                mbox = (struct imapc_mailbox *)mail->imail.mail.mail.box;
        }
        i_assert(mbox != NULL);
@@ -285,7 +284,6 @@ imapc_mail_send_fetch(struct mail *_mail, enum mail_fetch_field fields,
        str_truncate(str, str_len(str)-1);
        str_append_c(str, ')');
 
-       pool_ref(mail->imail.mail.pool);
        mail->fetching_fields |= fields;
        mail->fetch_count++;
        mail->fetch_sent = FALSE;
index 45be11e3a0e6dc868d31d9f77eb56f7b51951a8b..45eb05812897b96b9274d4cb99b10b6513d8556a 100644 (file)
@@ -443,6 +443,8 @@ static void imapc_mail_close(struct mail *_mail)
                buffer_free(&mail->body);
        mail->header_fetched = FALSE;
        mail->body_fetched = FALSE;
+
+       i_assert(mail->fetch_count == 0);
 }
 
 static int imapc_mail_get_hdr_hash(struct index_mail *imail)