From: Timo Sirainen Date: Mon, 17 Feb 2020 13:39:14 +0000 (+0200) Subject: lib-index: Fix potential crash when writing to unusable dovecot.index.cache X-Git-Tag: 2.3.11.2~599 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eaec3d6eb86d84a1b51b4ac7a33618f6c7cad68e;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Fix potential crash when writing to unusable dovecot.index.cache Broken by a4671d9c5744d728e030370a39df914cebefbefe --- 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); }