From: Timo Sirainen Date: Mon, 13 Apr 2026 15:28:43 +0000 (+0200) Subject: [PATCH 1/3] lib-storage: thread - Avoid excessive data stack growth with many Referen... X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u7^2~49 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=df1017145e4be4479514e5e4ea6251c2bf5fa21e;p=dovecot.git [PATCH 1/3] lib-storage: thread - Avoid excessive data stack growth with many References msgids Gbp-Pq: Name 0001-lib-storage-thread-Avoid-excessive-data-stack-growth.patch --- diff --git a/src/lib-storage/index/index-thread.c b/src/lib-storage/index/index-thread.c index 2b1ba04..e20a970 100644 --- a/src/lib-storage/index/index-thread.c +++ b/src/lib-storage/index/index-thread.c @@ -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: */