From: Timo Sirainen Date: Mon, 30 Nov 2020 18:37:46 +0000 (+0200) Subject: lib-storage: Fix potential assert-crash when adding missing attachment flags X-Git-Tag: 2.3.13~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b9c86377b7aa9692e2e1d138feda127c72051d6;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix potential assert-crash when adding missing attachment flags This happened only in a rather special condition. Added unit test to reproduce it. Fixes: Panic: file index-mail-headers.c: line 298 (index_mail_parse_header): assertion failed: (part != NULL) --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 61e6bfb3d8..a362942910 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -1412,11 +1412,18 @@ static int index_mail_parse_bodystructure(struct index_mail *mail, /* we haven't parsed the header yet */ const char *reason = index_mail_cache_reason(&mail->mail.mail, "bodystructure"); + bool orig_bodystructure_header = + data->save_bodystructure_header; + bool orig_bodystructure_body = + data->save_bodystructure_body; data->save_bodystructure_header = TRUE; data->save_bodystructure_body = TRUE; (void)get_cached_parts(mail); if (index_mail_parse_headers(mail, NULL, reason) < 0) { - data->save_bodystructure_header = TRUE; + data->save_bodystructure_header = + orig_bodystructure_header; + data->save_bodystructure_body = + orig_bodystructure_body; return -1; } i_assert(data->parser_ctx != NULL);