From: Timo Sirainen Date: Tue, 21 Sep 2021 13:14:12 +0000 (+0300) Subject: acl: Add data stack frame when iterating mailboxes X-Git-Tag: 2.3.17~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e05b6df33af67c841281a0e643e56f2c05354ec3;p=thirdparty%2Fdovecot%2Fcore.git acl: Add data stack frame when iterating mailboxes Avoids wasting memory when there are a lot of mailboxes. --- diff --git a/src/plugins/acl/acl-mailbox-list.c b/src/plugins/acl/acl-mailbox-list.c index f1d48176ee..18e04ad9b3 100644 --- a/src/plugins/acl/acl-mailbox-list.c +++ b/src/plugins/acl/acl-mailbox-list.c @@ -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). */