diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-11-03 02:42:06 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-11-03 03:12:34 +0100 |
commit | 487d08c2832368848f1235d781e114d343190476 (patch) | |
tree | 3b516627fe5d9053f5eb66ae1731459c44d7374f /base/util | |
parent | 7a66902bfba413ffee5d05f89297e0bf9c0c39eb (diff) | |
download | pki-487d08c2832368848f1235d781e114d343190476.tar.gz pki-487d08c2832368848f1235d781e114d343190476.tar.xz pki-487d08c2832368848f1235d781e114d343190476.zip |
Fixed resource leak in GenericASN1Extension.
The GenericASN1Extension has been modified to always close the
DerOutputStream instance.
https://fedorahosted.org/pki/ticket/2530
Diffstat (limited to 'base/util')
-rw-r--r-- | base/util/src/netscape/security/extensions/GenericASN1Extension.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/base/util/src/netscape/security/extensions/GenericASN1Extension.java b/base/util/src/netscape/security/extensions/GenericASN1Extension.java index 8b3b03fac..63c793c25 100644 --- a/base/util/src/netscape/security/extensions/GenericASN1Extension.java +++ b/base/util/src/netscape/security/extensions/GenericASN1Extension.java @@ -87,7 +87,6 @@ public class GenericASN1Extension extends Extension // Encode pattern private byte[] encodePattern() throws IOException, ParseException { - DerOutputStream os = new DerOutputStream(); DerOutputStream tmp = new DerOutputStream(); String type = null; String value = null; @@ -101,8 +100,10 @@ public class GenericASN1Extension extends Extension tmp.putDerValue(new DerValue(buff)); break; case '}': - os.write(DerValue.tag_Sequence, tmp); - return os.toByteArray(); + try (DerOutputStream os = new DerOutputStream()) { + os.write(DerValue.tag_Sequence, tmp); + return os.toByteArray(); + } default: type = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_TYPE); if (type.equalsIgnoreCase("integer")) { |