From 1c855ecdb945f937a52bb6e79c88fd2ae04f756f Mon Sep 17 00:00:00 2001 From: wolfie Date: Mon, 3 Jan 2022 20:19:59 -0600 Subject: [PATCH 1/2] fix: Fix file handle leak from 3x zip file logic backport --- .../me/coley/recaf/workspace/JarResource.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/java/me/coley/recaf/workspace/JarResource.java b/src/main/java/me/coley/recaf/workspace/JarResource.java index 351428904..23e74684f 100644 --- a/src/main/java/me/coley/recaf/workspace/JarResource.java +++ b/src/main/java/me/coley/recaf/workspace/JarResource.java @@ -63,19 +63,20 @@ protected Map loadClasses() throws IOException { // This may not always be ideal, but this way has one major bonus. It totally ignores CRC validity. // It also ignores a few other zip entry values. // Since somebody can intentionally write bogus data there to crash "ZipInputStream" this way works. - ZipFile zf = new ZipFile(getPath().toString()); - Enumeration entries = zf.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = entries.nextElement(); + try (ZipFile zf = new ZipFile(getPath().toString())) { + Enumeration entries = zf.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = entries.nextElement(); - if (shouldSkip(entry.getName())) - continue; - if (!loader.isValidClassEntry(entry)) - continue; + if (shouldSkip(entry.getName())) + continue; + if (!loader.isValidClassEntry(entry)) + continue; - InputStream zis = zf.getInputStream(entry); - byte[] in = IOUtil.toByteArray(zis); - loader.onClass(entry.getName(), in); + InputStream zis = zf.getInputStream(entry); + byte[] in = IOUtil.toByteArray(zis); + loader.onClass(entry.getName(), in); + } } } } From b3f13e6b3170d0362a22a37f2c232e4d71a3df8c Mon Sep 17 00:00:00 2001 From: wolfie Date: Mon, 3 Jan 2022 20:21:13 -0600 Subject: [PATCH 2/2] Increase version number --- pom.xml | 2 +- src/main/java/me/coley/recaf/Recaf.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 877abce47..684a0dfdf 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ me.coley recaf https://github.com/Col-E/Recaf/ - 2.21.9 + 2.21.10 Recaf A modern java bytecode editor diff --git a/src/main/java/me/coley/recaf/Recaf.java b/src/main/java/me/coley/recaf/Recaf.java index 86a472520..657e786c0 100644 --- a/src/main/java/me/coley/recaf/Recaf.java +++ b/src/main/java/me/coley/recaf/Recaf.java @@ -31,7 +31,7 @@ * @author Matt */ public class Recaf { - public static final String VERSION = "2.21.9"; + public static final String VERSION = "2.21.10"; public static final String DOC_URL = "https://col-e.github.io/Recaf-documentation/"; public static final int ASM_VERSION = Opcodes.ASM9; private static Controller currentController;