summary refs log tree commit diff
path: root/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs')
-rw-r--r--crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs33
1 files changed, 18 insertions, 15 deletions
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index a63ea7b7f..cb5b246eb 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -255,27 +255,30 @@ namespace Org.BouncyCastle.Cms
 				_out.Write(bytes, off, len);
 			}
 
-			public override void Close()
-			{
-				_out.Close();
+		    protected override void Dispose(bool disposing)
+		    {
+		        if (disposing)
+		        {
+                    _out.Dispose();
 
-				// TODO Parent context(s) should really be be closed explicitly
+                    // TODO Parent context(s) should really be be closed explicitly
 
-				_eiGen.Close();
+                    _eiGen.Close();
 
-                if (_outer.unprotectedAttributeGenerator != null)
-                {
-                    Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable());
+                    if (_outer.unprotectedAttributeGenerator != null)
+                    {
+                        Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable());
 
-                    Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector());
+                        Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector());
 
-                    _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs));
-                }
+                        _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs));
+                    }
 
-				_envGen.Close();
-				_cGen.Close();
-				base.Close();
-			}
+                    _envGen.Close();
+                    _cGen.Close();
+		        }
+		        base.Dispose(disposing);
+		    }
 		}
 	}
 }