]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: message-snippet - Free html parser before making new
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 28 Jan 2021 09:07:32 +0000 (11:07 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 4 Feb 2021 11:23:09 +0000 (13:23 +0200)
If html parser has already been initialized, free it before restarting
the parser.

Fixes memory leak introduced by 7f7be2cbf68f8a202a688d5bc50f82483d461643

src/lib-mail/message-snippet.c

index f99e37a2df93d87f9bc806082b551791f76815aa..4be6233c29127ce6f41639b29d88ba01c992fa94 100644 (file)
@@ -170,8 +170,12 @@ int message_snippet_generate(struct istream *input,
                        if (ct == NULL)
                                /* text/plain */ ;
                        else if (mail_html2text_content_type_match(ct)) {
+                               mail_html2text_deinit(&ctx.html2text);
                                ctx.html2text = mail_html2text_init(0);
-                               ctx.plain_output = buffer_create_dynamic(pool, 1024);
+                               if (ctx.plain_output == NULL) {
+                                       ctx.plain_output =
+                                               buffer_create_dynamic(pool, 1024);
+                               }
                        } else if (strncasecmp(ct, "text/", 5) != 0)
                                break;
                        continue;