]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Recreate mail.event when active mail is changed
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 11 Mar 2021 12:14:53 +0000 (14:14 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 15 Apr 2021 07:06:27 +0000 (07:06 +0000)
This makes sure that the two mails' events are treated completely
independently without any accidental spilling. It also prevents wasting
memory if each mail changes the event and grows the memory pool.

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

index 661d5ff718c590e5c6dc624b43ba1319bfb5c819..f92482e9ae522a96b35c03087b6308c3fa0fd838 100644 (file)
@@ -2057,8 +2057,10 @@ void index_mail_set_seq(struct mail *_mail, uint32_t seq, bool saving)
        mail_index_lookup_uid(_mail->transaction->view, seq,
                              &mail->mail.mail.uid);
 
-       if (_mail->event == NULL)
-               index_mail_init_event(_mail);
+       /* Recreate the mail event when changing mails. Even though the same
+          mail struct is reused, they are practically different mails. */
+       event_unref(&_mail->event);
+       index_mail_init_event(_mail);
        event_add_int(_mail->event, "seq", _mail->seq);
        event_add_int(_mail->event, "uid", _mail->uid);
        event_set_append_log_prefix(_mail->event, t_strdup_printf(