From 6df86fcb245e7cf8f199026269be644116efde9a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 13 Feb 2010 00:42:59 +0200 Subject: [PATCH] lib-storage: If plugin changes mail's input stream, don't assert-crash on close. --HG-- branch : HEAD --- src/lib-storage/index/index-mail.c | 9 +++++++-- src/lib-storage/index/index-mail.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 49e5c571c9..1dce8fa071 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -831,8 +831,13 @@ int index_mail_init_stream(struct index_mail *mail, data->initialized_wrapper_stream = TRUE; } - i_stream_set_destroy_callback(data->stream, - index_mail_stream_destroy_callback, mail); + if (!data->destroy_callback_set) { + /* do this only once in case a plugin changes the stream. + otherwise the check would break. */ + data->destroy_callback_set = TRUE; + i_stream_set_destroy_callback(data->stream, + index_mail_stream_destroy_callback, mail); + } if (hdr_size != NULL || body_size != NULL) (void)get_cached_msgpart_sizes(mail); diff --git a/src/lib-storage/index/index-mail.h b/src/lib-storage/index/index-mail.h index d9c643801e..33bc2e39bc 100644 --- a/src/lib-storage/index/index-mail.h +++ b/src/lib-storage/index/index-mail.h @@ -111,6 +111,7 @@ struct index_mail_data { unsigned int forced_no_caching:1; unsigned int destroying_stream:1; unsigned int initialized_wrapper_stream:1; + unsigned int destroy_callback_set:1; }; struct index_mail { -- 2.47.3