Skip to content

Commit f89a46b

Browse files
authored
Merge pull request #443 from win32kbase/master
Fix potential file handle leak from zip CRC logic backport
2 parents 1f8cc84 + 8b09c07 commit f89a46b

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<groupId>me.coley</groupId>
44
<artifactId>recaf</artifactId>
55
<url>https://github.com/Col-E/Recaf/</url>
6-
<version>2.21.9</version>
6+
<version>2.21.10</version>
77
<name>Recaf</name>
88
<description>A modern java bytecode editor</description>
99
<!-- Variables -->

src/main/java/me/coley/recaf/Recaf.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* @author Matt
3232
*/
3333
public class Recaf {
34-
public static final String VERSION = "2.21.9";
34+
public static final String VERSION = "2.21.10";
3535
public static final String DOC_URL = "https://col-e.github.io/Recaf-documentation/";
3636
public static final int ASM_VERSION = Opcodes.ASM9;
3737
private static Controller currentController;

src/main/java/me/coley/recaf/workspace/JarResource.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,20 @@ protected Map<String, byte[]> loadClasses() throws IOException {
6363
// This may not always be ideal, but this way has one major bonus. It totally ignores CRC validity.
6464
// It also ignores a few other zip entry values.
6565
// Since somebody can intentionally write bogus data there to crash "ZipInputStream" this way works.
66-
ZipFile zf = new ZipFile(getPath().toString());
67-
Enumeration<? extends ZipEntry> entries = zf.entries();
68-
while (entries.hasMoreElements()) {
69-
ZipEntry entry = entries.nextElement();
66+
try (ZipFile zf = new ZipFile(getPath().toString())) {
67+
Enumeration<? extends ZipEntry> entries = zf.entries();
68+
while (entries.hasMoreElements()) {
69+
ZipEntry entry = entries.nextElement();
7070

71-
if (shouldSkip(entry.getName()))
72-
continue;
73-
if (!loader.isValidClassEntry(entry))
74-
continue;
71+
if (shouldSkip(entry.getName()))
72+
continue;
73+
if (!loader.isValidClassEntry(entry))
74+
continue;
7575

76-
InputStream zis = zf.getInputStream(entry);
77-
byte[] in = IOUtil.toByteArray(zis);
78-
loader.onClass(entry.getName(), in);
76+
InputStream zis = zf.getInputStream(entry);
77+
byte[] in = IOUtil.toByteArray(zis);
78+
loader.onClass(entry.getName(), in);
79+
}
7980
}
8081
}
8182
}

0 commit comments

Comments
 (0)