]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Reduce data stack usage when finding attachment flags from mails with...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 26 Sep 2025 10:55:37 +0000 (13:55 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 14 Oct 2025 11:28:44 +0000 (11:28 +0000)
src/lib-storage/mail.c

index 74f1e1a489cf6c835ae8a203ffaf77e9e4351883..170b2edffbd67d017d86a3d563d6037b20fa1a87 100644 (file)
@@ -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)