diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-20 18:42:12 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-04-20 18:42:12 +0700 |
commit | 8ab0160708d540e42b086582bd1992f5269f7166 (patch) | |
tree | 528bf8667e4db801fe74f888ad51d08f7533ba27 /crypto/src/bcpg/PublicKeyPacket.cs | |
parent | Refactoring: reduced allocations (diff) | |
download | BouncyCastle.NET-ed25519-8ab0160708d540e42b086582bd1992f5269f7166.tar.xz |
Fix missing Dispose(s) of BcpgOutputStream
Diffstat (limited to 'crypto/src/bcpg/PublicKeyPacket.cs')
-rw-r--r-- | crypto/src/bcpg/PublicKeyPacket.cs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/crypto/src/bcpg/PublicKeyPacket.cs b/crypto/src/bcpg/PublicKeyPacket.cs index 89177ce84..639d5595c 100644 --- a/crypto/src/bcpg/PublicKeyPacket.cs +++ b/crypto/src/bcpg/PublicKeyPacket.cs @@ -98,20 +98,19 @@ namespace Org.BouncyCastle.Bcpg public virtual byte[] GetEncodedContents() { MemoryStream bOut = new MemoryStream(); - BcpgOutputStream pOut = new BcpgOutputStream(bOut); - - pOut.WriteByte((byte) version); - pOut.WriteInt((int) time); - - if (version <= 3) + using (var pOut = new BcpgOutputStream(bOut)) { - pOut.WriteShort((short) validDays); - } - - pOut.WriteByte((byte) algorithm); + pOut.WriteByte((byte)version); + pOut.WriteInt((int)time); - pOut.WriteObject((BcpgObject)key); + if (version <= 3) + { + pOut.WriteShort((short)validDays); + } + pOut.WriteByte((byte)algorithm); + pOut.WriteObject((BcpgObject)key); + } return bOut.ToArray(); } |