From 783f46efc6dc88c31cc17511fb11174daa685a54 Mon Sep 17 00:00:00 2001 From: Anders Musikka Date: Thu, 1 Sep 2022 12:08:36 +0200 Subject: [PATCH] Do not Return outputBuffer more than once --- src/ZstdSharp/CompressionStream.cs | 3 ++- src/ZstdSharp/DecompressionStream.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ZstdSharp/CompressionStream.cs b/src/ZstdSharp/CompressionStream.cs index e9fee1f..01719be 100644 --- a/src/ZstdSharp/CompressionStream.cs +++ b/src/ZstdSharp/CompressionStream.cs @@ -104,9 +104,10 @@ private void ReleaseUnmanagedResources() if (!preserveCompressor) { compressor.Dispose(); - compressor = null; } + compressor = null; + ArrayPool.Shared.Return(outputBuffer); } diff --git a/src/ZstdSharp/DecompressionStream.cs b/src/ZstdSharp/DecompressionStream.cs index ee9063b..bfc49c7 100644 --- a/src/ZstdSharp/DecompressionStream.cs +++ b/src/ZstdSharp/DecompressionStream.cs @@ -73,8 +73,9 @@ protected override void Dispose(bool disposing) if (!preserveDecompressor) { decompressor.Dispose(); - decompressor = null; } + + decompressor = null; ArrayPool.Shared.Return(inputBuffer); }