From: Timo Sirainen Date: Tue, 24 Jul 2018 11:55:25 +0000 (+0300) Subject: lib-mail: If message_part_data.content_type is set, make sure content_subtype isn... X-Git-Tag: 2.3.9~1578 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd296f19d085a43f07733a8fc110e7a614151b12;p=thirdparty%2Fdovecot%2Fcore.git lib-mail: If message_part_data.content_type is set, make sure content_subtype isn't NULL This fixes a crash in index_mail_find_first_text_mime_part() where snippet generation assumed that content_subtype isn't NULL. --- diff --git a/src/lib-mail/message-part-data.c b/src/lib-mail/message-part-data.c index ffae458f55..1c7ca9c3e5 100644 --- a/src/lib-mail/message-part-data.c +++ b/src/lib-mail/message-part-data.c @@ -320,6 +320,12 @@ parse_content_type(struct message_part_data *data, } str_truncate(str, i); data->content_type = p_strdup(pool, str_c(str)); + if (data->content_subtype == NULL) { + /* The Content-Type is invalid. Don't leave it NULL so that + callers can assume that if content_type != NULL, + content_subtype != NULL also. */ + data->content_subtype = p_strdup(pool, ""); + } if (ret < 0) { /* Content-Type is broken, but we wanted to get it as well as