]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
sdbox: saving - Add data stack frame when assigning UIDs for mails
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 27 Dec 2022 10:08:43 +0000 (05:08 -0500)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 11 Jan 2023 21:50:37 +0000 (23:50 +0200)
Since each saved mail was already using memory, this wasn't causing much
extra memory usage.

src/lib-storage/index/dbox-single/sdbox-save.c

index 30d88bc69ce253812ba4ed1b22c852e7af1ddd3c..e7a6034b8d4d676e957c7db7ad004ab62f5cb10d 100644 (file)
@@ -238,22 +238,24 @@ static int dbox_save_assign_uids(struct sdbox_save_context *ctx,
        struct seq_range_iter iter;
        unsigned int i, count, n = 0;
        uint32_t uid;
-       bool ret;
+       int ret = 0;
 
        seq_range_array_iter_init(&iter, uids);
        files = array_get(&ctx->files, &count);
-       for (i = 0; i < count; i++) {
+       for (i = 0; i < count && ret == 0; i++) T_BEGIN {
                struct sdbox_file *sfile = (struct sdbox_file *)files[i];
 
-               ret = seq_range_array_iter_nth(&iter, n++, &uid);
-               i_assert(ret);
-               if (sdbox_file_assign_uid(sfile, uid) < 0)
-                       return -1;
-               if (ctx->ctx.highest_pop3_uidl_seq == i+1) {
+               bool more = seq_range_array_iter_nth(&iter, n++, &uid);
+               i_assert(more);
+               ret = sdbox_file_assign_uid(sfile, uid);
+               if (ret == 0 && ctx->ctx.highest_pop3_uidl_seq == i+1) {
                        index_pop3_uidl_set_max_uid(&ctx->mbox->box,
                                ctx->ctx.trans, uid);
                }
-       }
+       } T_END;
+       if (ret < 0)
+               return -1;
+
        i_assert(!seq_range_array_iter_nth(&iter, n, &uid));
        return 0;
 }