]> dgit.raspbian.org Git - dovecot.git/commitdiff
[PATCH 1/3] lib-storage: thread - Avoid excessive data stack growth with many Referen...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 13 Apr 2026 15:28:43 +0000 (17:28 +0200)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
Gbp-Pq: Name 0001-lib-storage-thread-Avoid-excessive-data-stack-growth.patch

src/lib-storage/index/index-thread.c

index 2b1ba045ac73f78e52440b5ce5ed9e3c2e7c0b43..e20a97072cabb677b2ce6f5516606c246ff9b67c 100644 (file)
@@ -93,9 +93,11 @@ mail_strmap_rec_get_msgid(struct mail_thread_context *ctx,
 
        /* get the nth message-id */
        msgid = message_id_get_next(&msgids);
-       if (msgid != NULL) {
-               for (; n > 0; n--)
+       if (msgid != NULL && n > 0) {
+               for (; n > 1; n--) T_BEGIN {
                        msgid = message_id_get_next(&msgids);
+               } T_END;
+               msgid = message_id_get_next(&msgids);
        }
 
        if (msgid == NULL) {
@@ -266,12 +268,18 @@ mail_thread_map_add_mail(struct mail_thread_context *ctx, struct mail *mail)
        msgid = message_id_get_next(&references);
        if (msgid != NULL) {
                ref_index = MAIL_THREAD_NODE_REF_REFERENCES1;
+               mail_index_strmap_view_sync_add(ctx->strmap_sync,
+                                               mail->uid, ref_index, msgid);
                do {
-                       mail_index_strmap_view_sync_add(ctx->strmap_sync,
-                                                       mail->uid,
-                                                       ref_index, msgid);
-                       ref_index++;
-                       msgid = message_id_get_next(&references);
+                       T_BEGIN {
+                               ref_index++;
+                               msgid = message_id_get_next(&references);
+                               if (msgid != NULL) {
+                                       mail_index_strmap_view_sync_add(
+                                               ctx->strmap_sync, mail->uid,
+                                               ref_index, msgid);
+                               }
+                       } T_END;
                } while (msgid != NULL);
        } else {
                /* no References:, use In-Reply-To: */