changeset 22621:a91a473c65f7

lib-storage: Fix assert-crash when searching header and MIMEPART For now this is just a bit kludgy workaround. The proper fix requires larger changes, which aren't worth the effort right now. For example: doveadm fetch -u testuser uid MAILBOX inbox FROM foo MIMEPART FILENAME CONTAINS bar BODY baz Crashes with: Panic: file index-mail-headers.c: line 294 (index_mail_parse_header): assertion failed: (part != NULL)
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 19 Oct 2017 14:39:01 +0300
parents 71665d0c1382
children c0417a608a71
files src/lib-storage/index/index-search.c
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-search.c	Thu Oct 19 15:39:28 2017 +0300
+++ b/src/lib-storage/index/index-search.c	Thu Oct 19 14:39:01 2017 +0300
@@ -768,7 +768,17 @@
 			search_cur_mail_failed(ctx);
 			failed = TRUE;
 		} else {
+			/* FIXME: The header parsing here is an optimization to
+			   avoid parsing the header twice: First when checking
+			   whether the search matches, and secondly when
+			   generating wanted fields. However, if we already
+			   know that we want to generate a BODYSTRUCTURE reply,
+			   index_mail_parse_header() must have a non-NULL part
+			   parameter. That's not easily possible at this point
+			   without larger code changes, so for now we'll just
+			   disable this optimization for that case. */
 			hdr_ctx.parse_headers =
+				!hdr_ctx.imail->data.save_bodystructure_header &&
 				index_mail_want_parse_headers(hdr_ctx.imail);
 			if (hdr_ctx.parse_headers) {
 				index_mail_parse_header_init(hdr_ctx.imail,