From a6f935ed681b9d13e1b0b1170a1bbb38f232203f Mon Sep 17 00:00:00 2001 From: Ahmed Ashour Date: Sun, 31 Mar 2019 20:33:45 +0200 Subject: [PATCH] fix: close resource (PR #546) --- jadx-core/src/main/java/jadx/core/Jadx.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/Jadx.java b/jadx-core/src/main/java/jadx/core/Jadx.java index 61de7ab72fe..d961f1be984 100644 --- a/jadx-core/src/main/java/jadx/core/Jadx.java +++ b/jadx-core/src/main/java/jadx/core/Jadx.java @@ -1,5 +1,6 @@ package jadx.core; +import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Enumeration; @@ -126,10 +127,12 @@ public static String getVersion() { if (classLoader != null) { Enumeration resources = classLoader.getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { - Manifest manifest = new Manifest(resources.nextElement().openStream()); - String ver = manifest.getMainAttributes().getValue("jadx-version"); - if (ver != null) { - return ver; + try (InputStream is = resources.nextElement().openStream()) { + Manifest manifest = new Manifest(is); + String ver = manifest.getMainAttributes().getValue("jadx-version"); + if (ver != null) { + return ver; + } } } }