From 3ff688fba2a4320eb8f68ae33e434867c66f8b54 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Thu, 23 Oct 2025 10:48:18 +0100 Subject: [PATCH] clear and null check --- src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs b/src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs index 67d1c4cd..a035e890 100644 --- a/src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs +++ b/src/SharpCompress/Compressors/LZMA/LZ/LzOutWindow.cs @@ -24,6 +24,7 @@ internal class OutWindow : IDisposable if (_windowSize != windowSize) { _buffer = ArrayPool.Shared.Rent(windowSize); + Array.Clear(_buffer, 0, windowSize); } else { @@ -40,6 +41,10 @@ internal class OutWindow : IDisposable public void Dispose() { ReleaseStream(); + if (_buffer is null) + { + return; + } ArrayPool.Shared.Return(_buffer); _buffer = null; }