]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mdbox: Avoid calling container_of() with a NULL pointer
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 4 Oct 2021 14:25:05 +0000 (17:25 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 5 Oct 2021 09:57:30 +0000 (09:57 +0000)
src/lib-storage/index/dbox-multi/mdbox-save.c

index 8a614e7c51faf6d8028c33ece64e2f010b317f17..c0dcf5b480757e98979298b00a23dec4eccf7751 100644 (file)
@@ -100,12 +100,13 @@ struct mail_save_context *
 mdbox_save_alloc(struct mailbox_transaction_context *t)
 {
        struct mdbox_mailbox *mbox = MDBOX_MAILBOX(t->box);
-       struct mdbox_save_context *ctx = MDBOX_SAVECTX(t->save_ctx);
+       struct mdbox_save_context *ctx;
 
        i_assert((t->flags & MAILBOX_TRANSACTION_FLAG_EXTERNAL) != 0);
 
-       if (ctx != NULL) {
+       if (t->save_ctx != NULL) {
                /* use the existing allocated structure */
+               ctx = MDBOX_SAVECTX(t->save_ctx);
                ctx->cur_file = NULL;
                ctx->ctx.failed = FALSE;
                ctx->ctx.finished = FALSE;