]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix unnecessary data stack growth when iterating mailboxes
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 26 Dec 2022 21:48:27 +0000 (23:48 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 26 Dec 2022 21:48:27 +0000 (23:48 +0200)
When listing mailbox list indexes, it was possible that each iteration
increased the data stack memory usage. It was all freed at the end though,
so this didn't cause any permanent leaks.

Broken by 4fdb040d2471c6e5006579bef1dd0586f89c8570

src/lib-storage/list/mailbox-list-index-iter.c

index e061069744b92150668211f7dd718d1dfeab1145..c47732d166405c844bd618d3d2dbbf9ec4617239 100644 (file)
@@ -160,7 +160,7 @@ mailbox_list_index_update_next(struct mailbox_list_index_iterate_context *ctx,
        } else {
                while (node->next == NULL) {
                        node = node->parent;
-                       if (node != NULL) {
+                       if (node != NULL) T_BEGIN {
                                /* The storage name kept in the iteration context
                                   is escaped. To calculate the right truncation
                                   margin, the length of the name must be
@@ -173,7 +173,7 @@ mailbox_list_index_update_next(struct mailbox_list_index_iterate_context *ctx,
                                ctx->parent_len -= str_len(escaped_name);
                                if (node->parent != NULL)
                                        ctx->parent_len--;
-                       }
+                       } T_END;
                        if (node == NULL) {
                                /* last one */
                                ctx->next_node = NULL;