]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix crash in mail_get_parts() with a special plugin
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 26 Apr 2017 20:43:24 +0000 (23:43 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 27 Apr 2017 07:30:31 +0000 (10:30 +0300)
If plugin hooks into mail_get_stream() which causes data->parts to be set,
this code crashed with:

Panic: file index-mail.c: line 1163 (index_mail_parse_body): assertion failed: (data->parser_ctx != NULL)

src/lib-storage/index/index-mail.c

index 9167ea3f6ac5cc291652f8335389a32c9397dc9d..f689c3693ec02243fea002531f313e59c0b4074c 100644 (file)
@@ -327,11 +327,14 @@ int index_mail_get_parts(struct mail *_mail, struct message_part **parts_r)
                        index_mail_cache_reason(_mail, "mime parts");
                if (index_mail_parse_headers(mail, NULL, reason) < 0)
                        return -1;
+               /* parts may be set now as a result of some plugin */
        }
 
-       data->save_message_parts = TRUE;
-       if (index_mail_parse_body(mail, 0) < 0)
-               return -1;
+       if (data->parts == NULL) {
+               data->save_message_parts = TRUE;
+               if (index_mail_parse_body(mail, 0) < 0)
+                       return -1;
+       }
 
        *parts_r = data->parts;
        return 0;