1 files changed, 13 insertions, 12 deletions
diff --git a/crypto/src/cms/CMSUtils.cs b/crypto/src/cms/CMSUtils.cs
index 281e1e73a..0041d2fac 100644
--- a/crypto/src/cms/CMSUtils.cs
+++ b/crypto/src/cms/CMSUtils.cs
@@ -33,26 +33,27 @@ namespace Org.BouncyCastle.Cms
}
}
- internal static ContentInfo ReadContentInfo(
- byte[] input)
+ internal static ContentInfo ReadContentInfo(byte[] input)
{
- // enforce limit checking as from a byte array
- return ReadContentInfo(new Asn1InputStream(input));
- }
+ using (var asn1In = new Asn1InputStream(input))
+ {
+ return ReadContentInfo(asn1In);
+ }
+ }
- internal static ContentInfo ReadContentInfo(
- Stream input)
+ internal static ContentInfo ReadContentInfo(Stream input)
{
- // enforce some limit checking
- return ReadContentInfo(new Asn1InputStream(input, MaximumMemory));
+ using (var asn1In = new Asn1InputStream(input, MaximumMemory, leaveOpen: true))
+ {
+ return ReadContentInfo(asn1In);
+ }
}
- private static ContentInfo ReadContentInfo(
- Asn1InputStream aIn)
+ private static ContentInfo ReadContentInfo(Asn1InputStream asn1In)
{
try
{
- return ContentInfo.GetInstance(aIn.ReadObject());
+ return ContentInfo.GetInstance(asn1In.ReadObject());
}
catch (IOException e)
{
|