summary refs log tree commit diff
path: root/crypto/src/util/bzip2/CBZip2OutputStream.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-06 22:44:32 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-03-06 22:44:32 +0700
commit44844b4c0e0df30a72f1659b9904749f456f2545 (patch)
treed727163d1ff7d8126c640b4263aed0f041de1e8e /crypto/src/util/bzip2/CBZip2OutputStream.cs
parentUse Id instead of ToString (diff)
downloadBouncyCastle.NET-ed25519-44844b4c0e0df30a72f1659b9904749f456f2545.tar.xz
Support leaveOpen in decompressors
Diffstat (limited to 'crypto/src/util/bzip2/CBZip2OutputStream.cs')
-rw-r--r--crypto/src/util/bzip2/CBZip2OutputStream.cs22
1 files changed, 13 insertions, 9 deletions
diff --git a/crypto/src/util/bzip2/CBZip2OutputStream.cs b/crypto/src/util/bzip2/CBZip2OutputStream.cs
index d1400c7c4..10b76c677 100644
--- a/crypto/src/util/bzip2/CBZip2OutputStream.cs
+++ b/crypto/src/util/bzip2/CBZip2OutputStream.cs
@@ -424,11 +424,7 @@ namespace Org.BouncyCastle.Utilities.Bzip2
         {
             if (disposing)
             {
-                if (!closed)
-                {
-                    Finish();
-                    closed = true;
-                }
+                ImplDisposing(disposeOutput: false);
             }
             base.Dispose(disposing);
         }
@@ -437,14 +433,22 @@ namespace Org.BouncyCastle.Utilities.Bzip2
         {
             if (disposing)
             {
-                if (!closed)
+                ImplDisposing(disposeOutput: true);
+            }
+            base.Dispose(disposing);
+        }
+
+        private void ImplDisposing(bool disposeOutput)
+        {
+            if (!closed)
+            {
+                Finish();
+                closed = true;
+                if (disposeOutput)
                 {
-                    Finish();
-                    closed = true;
                     this.bsStream.Dispose();
                 }
             }
-            base.Dispose(disposing);
         }
 
         public void Finish()