From fa7e6314cb085fad66311769082c84d9fc2b7660 Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 27 Sep 2023 15:10:39 +0200 Subject: [PATCH] remove possible mem leak in error cases by brotli compression too --- C/zstdmt/brotli-mt_compress.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/C/zstdmt/brotli-mt_compress.c b/C/zstdmt/brotli-mt_compress.c index d8dad2b4..c0db8272 100644 --- a/C/zstdmt/brotli-mt_compress.c +++ b/C/zstdmt/brotli-mt_compress.c @@ -480,6 +480,15 @@ size_t BROTLIMT_compressCCtx(BROTLIMT_CCtx * ctx, BROTLIMT_RdWr_t * rdwr) retval_of_thread = p; } + /* move remaining done/busy entries to free list */ + while (!list_empty(&ctx->writelist_done)) { + struct list_head *entry = list_first(&ctx->writelist_done); + list_move(entry, &ctx->writelist_free); + } + while (!list_empty(&ctx->writelist_busy)) { + struct list_head* entry = list_first(&ctx->writelist_busy); + list_move(entry, &ctx->writelist_free); + } /* clean up lists */ while (!list_empty(&ctx->writelist_free)) { struct writelist *wl;