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

index 6349eff1e7a89b600d6b5b5247a0d66b1cb31e8d..03e24ab586846c78faa0fa675090b8c304ba8373 100644 (file)
@@ -57,12 +57,13 @@ struct mail_save_context *
 sdbox_save_alloc(struct mailbox_transaction_context *t)
 {
        struct sdbox_mailbox *mbox = SDBOX_MAILBOX(t->box);
-       struct sdbox_save_context *ctx = SDBOX_SAVECTX(t->save_ctx);
+       struct sdbox_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 = SDBOX_SAVECTX(t->save_ctx);
                ctx->cur_file = NULL;
                ctx->ctx.failed = FALSE;
                ctx->ctx.finished = FALSE;