From a070493fbab0fe75e397e75bf7c0fd3ff18b75ed Mon Sep 17 00:00:00 2001 From: majorro Date: Mon, 13 Jan 2025 23:26:49 +0300 Subject: [PATCH] window null checks --- src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs index be55b7bb..6cadcede 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs @@ -29,6 +29,7 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable if (!externalWindow) { ArrayPool.Shared.Return(window); + window = null; } disposed = true; } @@ -125,11 +126,11 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable private void Init(byte[] window) { - if (window is null) + if (this.window is null && window is null) { this.window = ArrayPool.Shared.Rent(PackDef.MAXWINSIZE); } - else + else if (window is not null) { this.window = window; externalWindow = true;