The GenericASN1Extension has been modified to always close the
DerOutputStream instance.

https://fedorahosted.org/pki/ticket/2530

Pushed to master under trivial/one-liner rule.

--
Endi S. Dewata
>From 487d08c2832368848f1235d781e114d343190476 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edew...@redhat.com>
Date: Thu, 3 Nov 2016 02:42:06 +0100
Subject: [PATCH] Fixed resource leak in GenericASN1Extension.

The GenericASN1Extension has been modified to always close the
DerOutputStream instance.

https://fedorahosted.org/pki/ticket/2530
---
 .../src/netscape/security/extensions/GenericASN1Extension.java     | 7 ++++---
 1 file 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 8b3b03fac70a4f13f82f37b080c869690a8df0e3..63c793c251d2d9dd472987e31ca1c2f5d7575245 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")) {
-- 
2.5.5

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to