diff options
Diffstat (limited to 'crypto/src/util/zlib/ZOutputStream.cs')
-rw-r--r-- | crypto/src/util/zlib/ZOutputStream.cs | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/crypto/src/util/zlib/ZOutputStream.cs b/crypto/src/util/zlib/ZOutputStream.cs index ecf33cddf..04b7bb8e5 100644 --- a/crypto/src/util/zlib/ZOutputStream.cs +++ b/crypto/src/util/zlib/ZOutputStream.cs @@ -113,26 +113,7 @@ namespace Org.BouncyCastle.Utilities.Zlib { if (disposing) { - if (!closed) - { - try - { - try - { - Finish(); - } - catch (IOException) - { - // Ignore - } - } - finally - { - this.closed = true; - End(); - output = null; - } - } + ImplDisposing(disposeOutput: false); } base.Dispose(disposing); } @@ -141,29 +122,37 @@ namespace Org.BouncyCastle.Utilities.Zlib { if (disposing) { - if (!closed) + ImplDisposing(disposeOutput: true); + } + base.Dispose(disposing); + } + + private void ImplDisposing(bool disposeOutput) + { + if (!closed) + { + try { try { - try - { - Finish(); - } - catch (IOException) - { - // Ignore - } + Finish(); } - finally + catch (IOException) + { + // Ignore + } + } + finally + { + this.closed = true; + End(); + if (disposeOutput) { - this.closed = true; - End(); output.Dispose(); - output = null; } + output = null; } } - base.Dispose(disposing); } public virtual void End() |