1 files changed, 43 insertions, 31 deletions
diff --git a/crypto/src/util/zlib/ZOutputStream.cs b/crypto/src/util/zlib/ZOutputStream.cs
index dcb93f97b..301516e57 100644
--- a/crypto/src/util/zlib/ZOutputStream.cs
+++ b/crypto/src/util/zlib/ZOutputStream.cs
@@ -109,49 +109,61 @@ namespace Org.BouncyCastle.Utilities.Zlib
this.z.deflateInit(level, nowrap);
}
-#if PORTABLE
- protected override void Dispose(bool disposing)
+ protected void Detach(bool disposing)
{
if (disposing)
{
- if (closed)
- return;
-
- DoClose();
+ if (!closed)
+ {
+ try
+ {
+ try
+ {
+ Finish();
+ }
+ catch (IOException)
+ {
+ // Ignore
+ }
+ }
+ finally
+ {
+ this.closed = true;
+ End();
+ output = null;
+ }
+ }
}
base.Dispose(disposing);
}
-#else
- public override void Close()
- {
- if (closed)
- return;
-
- DoClose();
- base.Close();
- }
-#endif
- private void DoClose()
+ protected override void Dispose(bool disposing)
{
- try
+ if (disposing)
{
- try
- {
- Finish();
- }
- catch (IOException)
+ if (!closed)
{
- // Ignore
+ try
+ {
+ try
+ {
+ Finish();
+ }
+ catch (IOException)
+ {
+ // Ignore
+ }
+ }
+ finally
+ {
+ this.closed = true;
+ End();
+ Platform.Dispose(output);
+ output = null;
+ }
}
}
- finally
- {
- this.closed = true;
- End();
- Platform.Dispose(output);
- output = null;
- }
+ base.Dispose(disposing);
}
public virtual void End()
|