From eaec3d6eb86d84a1b51b4ac7a33618f6c7cad68e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 17 Feb 2020 15:39:14 +0200 Subject: [PATCH] lib-index: Fix potential crash when writing to unusable dovecot.index.cache Broken by a4671d9c5744d728e030370a39df914cebefbefe --- src/lib-index/mail-cache-transaction.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib-index/mail-cache-transaction.c b/src/lib-index/mail-cache-transaction.c index 43779ba62d..22b148050f 100644 --- a/src/lib-index/mail-cache-transaction.c +++ b/src/lib-index/mail-cache-transaction.c @@ -264,8 +264,9 @@ static int mail_cache_transaction_lock(struct mail_cache_transaction_ctx *ctx) cache->last_stat_size + ctx->cache_data->used >= cache_max_size) { /* Looks like cache file is becoming too large. Try to compress it to free up some space. */ - if (cache->hdr->continued_record_count > 0 || - cache->hdr->deleted_record_count > 0) + if (!MAIL_CACHE_IS_UNUSABLE(cache) && + (cache->hdr->continued_record_count > 0 || + cache->hdr->deleted_record_count > 0)) (void)mail_cache_transaction_compress(ctx); } -- 2.47.3