diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 0c24b7468..256a851d1 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -238,6 +238,7 @@ Miha
Mike Davis
Mike Roberts
mnowostawski
+Mounir
Nathan Beyer
Nick Chalko
Nick Fortescue
diff --git a/WHATSNEW b/WHATSNEW
index 1aab08cd3..5c1eaec42 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -55,6 +55,10 @@ Fixed bugs:
error output stream some "Pipe broken" errors.
Bugzilla Report 48789.
+ * ZipFile failed to clean up some resources which could lead to
+ OutOfMemoryException while unzipping large archives.
+ Bugzilla Report 42969.
+
Other changes:
--------------
diff --git a/contributors.xml b/contributors.xml
index f0bf380dc..d68bbcc3c 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -976,6 +976,9 @@
mnowostawski
+
+ Mounir
+
Nathan
Beyer
diff --git a/src/main/org/apache/tools/zip/ZipFile.java b/src/main/org/apache/tools/zip/ZipFile.java
index acb6f3d1b..074792018 100644
--- a/src/main/org/apache/tools/zip/ZipFile.java
+++ b/src/main/org/apache/tools/zip/ZipFile.java
@@ -269,7 +269,13 @@ public class ZipFile {
return bis;
case ZipEntry.DEFLATED:
bis.addDummy();
- return new InflaterInputStream(bis, new Inflater(true));
+ final Inflater inflater = new Inflater(true);
+ return new InflaterInputStream(bis, inflater) {
+ public void close() throws IOException {
+ super.close();
+ inflater.end();
+ }
+ };
default:
throw new ZipException("Found unsupported compression method "
+ ze.getMethod());