]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
acl: Add data stack frame when iterating mailboxes
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 21 Sep 2021 13:14:12 +0000 (16:14 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 22 Sep 2021 11:11:23 +0000 (11:11 +0000)
Avoids wasting memory when there are a lot of mailboxes.

src/plugins/acl/acl-mailbox-list.c

index f1d48176ee07d02b14522f1e92e5e19e60678bd8..18e04ad9b3b0c06300dcf789ab446b879a626030 100644 (file)
@@ -221,7 +221,16 @@ acl_mailbox_list_iter_next_info(struct mailbox_list_iterate_context *_ctx)
        struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(_ctx->list);
        const struct mailbox_info *info;
 
-       while ((info = alist->module_ctx.super.iter_next(_ctx)) != NULL) {
+       for (;;) {
+               /* Normally the data stack frame is in mailbox_list_iter_next(),
+                  but we're bypassing it here by calling super.iter_next()
+                  directly. */
+               T_BEGIN {
+                       info = alist->module_ctx.super.iter_next(_ctx);
+               } T_END;
+               if (info == NULL)
+                       break;
+
                /* if we've a list of mailboxes with LOOKUP rights, skip the
                   mailboxes not in the list (since we know they can't be
                   visible to us). */