diff --git a/src/SharpCompress/IO/SharpCompressStream.Async.cs b/src/SharpCompress/IO/SharpCompressStream.Async.cs index 8e2adc8f8..bd17a0619 100644 --- a/src/SharpCompress/IO/SharpCompressStream.Async.cs +++ b/src/SharpCompress/IO/SharpCompressStream.Async.cs @@ -154,7 +154,7 @@ public override async ValueTask DisposeAsync() #if DEBUG_STREAMS this.DebugDispose(typeof(SharpCompressStream)); #endif - if (_isDisposed || LeaveOpen) + if (_isDisposed) { return; } @@ -166,7 +166,10 @@ public override async ValueTask DisposeAsync() } _isDisposed = true; await base.DisposeAsync(); - + if (this.LeaveOpen) + { + return; + } await Stream.DisposeAsync(); if (_buffer != null) { diff --git a/src/SharpCompress/IO/SharpCompressStream.cs b/src/SharpCompress/IO/SharpCompressStream.cs index f5283b5eb..c53c59fe4 100644 --- a/src/SharpCompress/IO/SharpCompressStream.cs +++ b/src/SharpCompress/IO/SharpCompressStream.cs @@ -141,7 +141,7 @@ protected override void Dispose(bool disposing) #if DEBUG_STREAMS this.DebugDispose(typeof(SharpCompressStream)); #endif - if (_isDisposed || this.LeaveOpen) + if (_isDisposed) { return; } @@ -154,6 +154,10 @@ protected override void Dispose(bool disposing) } _isDisposed = true; base.Dispose(disposing); + if (this.LeaveOpen) + { + return; + } if (disposing) { Stream.Dispose();