]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Don't use data stack for building index header update buffer
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 21 Sep 2021 13:42:39 +0000 (16:42 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 22 Sep 2021 11:11:23 +0000 (11:11 +0000)
The header update can be large (e.g. dovecot.list.index with many
mailboxes) and grow data stack unnecessarily.

src/lib-index/mail-index-transaction-export.c

index 4f903cf8e7f450e1c6d20d5ad9e15bad34e1a8e7..2aced679a39f84786df91cc62147152066f5cb43 100644 (file)
@@ -206,7 +206,7 @@ log_append_ext_hdr_update(struct mail_index_export_context *ctx,
        data = hdr->data;
        mask = hdr->mask;
 
-       buf = t_buffer_create(256);
+       buf = buffer_create_dynamic(default_pool, 256);
        for (offset = 0; offset <= hdr->alloc_size; offset++) {
                if (offset < hdr->alloc_size && mask[offset] != 0) {
                        if (!started) {
@@ -233,6 +233,7 @@ log_append_ext_hdr_update(struct mail_index_export_context *ctx,
                buffer_append_zero(buf, 4 - buf->used % 4);
        log_append_buffer(ctx, buf, use_32 ? MAIL_TRANSACTION_EXT_HDR_UPDATE32 :
                          MAIL_TRANSACTION_EXT_HDR_UPDATE);
+       buffer_free(&buf);
 }
 
 static void