From: Timo Sirainen Date: Fri, 26 Sep 2025 10:55:37 +0000 (+0300) Subject: lib-storage: Reduce data stack usage when finding attachment flags from mails with... X-Git-Tag: 2.4.2~92 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22785276629e1d5a6b45af11633eaefa2dddd35c;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Reduce data stack usage when finding attachment flags from mails with many MIME parts --- diff --git a/src/lib-storage/mail.c b/src/lib-storage/mail.c index 74f1e1a489..170b2edffb 100644 --- a/src/lib-storage/mail.c +++ b/src/lib-storage/mail.c @@ -588,13 +588,13 @@ static bool mail_message_has_attachment(struct message_part *part, const struct message_part_attachment_settings *set) { - for (; part != NULL; part = part->next) { - if (message_part_is_attachment(part, set) || - mail_message_has_attachment(part->children, set)) - return TRUE; - } + bool has_attachment = FALSE; + for (; part != NULL && !has_attachment; part = part->next) T_BEGIN { + has_attachment = message_part_is_attachment(part, set) || + mail_message_has_attachment(part->children, set); + } T_END; - return FALSE; + return has_attachment; } bool mail_has_attachment_keywords(struct mail *mail)