From: Timo Sirainen Date: Tue, 30 Mar 2021 13:50:13 +0000 (+0300) Subject: lib-index: Avoid accessing already freed "reason" when purging X-Git-Tag: 2.3.15~126 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=57069b23e6515875796473bdd4ec4bf90343fb25;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Avoid accessing already freed "reason" when purging Broken by 4b60d609c05d334d29a72c6dbbe301a66f518089 --- diff --git a/src/lib-index/mail-cache-purge.c b/src/lib-index/mail-cache-purge.c index c61c071295..5a56f36d11 100644 --- a/src/lib-index/mail-cache-purge.c +++ b/src/lib-index/mail-cache-purge.c @@ -645,7 +645,9 @@ bool mail_cache_need_purge(struct mail_cache *cache, const char **reason_r) } i_assert(cache->need_purge_reason != NULL); - *reason_r = cache->need_purge_reason; + /* t_strdup() the reason in case it gets freed (or replaced) + before it's used */ + *reason_r = t_strdup(cache->need_purge_reason); return TRUE; }