]> 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)
committerMarkus Valentin <markus.valentin@open-xchange.com>
Wed, 28 Dec 2022 06:57:01 +0000 (07:57 +0100)
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 be8b265d36c30d9a5083d579d8f9cf53a57d9573..680808e3475da1c274f991824c915d41dbc339d1 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;