From: Timo Sirainen Date: Mon, 30 Nov 2020 20:10:28 +0000 (+0200) Subject: lib-storage: Fix potential assert-crash when fetching body snippet X-Git-Tag: 2.3.13~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=090bad0fa941d0eeeaf19903aea3755821dcda9b;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Fix potential assert-crash when fetching body snippet This happened only in a rather special condition. Added unit test to reproduce it. Fixes: Panic: file message-part-data.c: line 28 (message_part_data_is_plain_7bit): assertion failed: (data != NULL) --- diff --git a/src/lib-storage/index/index-mail-headers.c b/src/lib-storage/index/index-mail-headers.c index d67b96e831..d63c24fbbe 100644 --- a/src/lib-storage/index/index-mail-headers.c +++ b/src/lib-storage/index/index-mail-headers.c @@ -417,7 +417,7 @@ static void index_mail_init_parser(struct index_mail *mail) index_mail_set_message_parts_corrupted(&mail->mail.mail, error); data->parts = NULL; } - if (data->parts == NULL) { + if (data->parts == NULL || data->parts != parts) { /* The previous parsing didn't finish, so we're re-parsing the header. The new parts don't have data filled anymore. */