]> source.dussan.org Git - poi.git/commitdiff
Fix two more places where wrong/invalid files can lead to file-handle leaks currently
authorDominik Stadler <centic@apache.org>
Sat, 2 Apr 2016 11:01:56 +0000 (11:01 +0000)
committerDominik Stadler <centic@apache.org>
Sat, 2 Apr 2016 11:01:56 +0000 (11:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1737489 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/openxml4j/opc/OPCPackage.java
src/ooxml/java/org/apache/poi/openxml4j/opc/internal/ZipHelper.java

index 3eb9b6df6f85f94b339d0282dbf35304f06bef69..b1b11b512d8a6f469fcb4f81e480975ded70b232 100644 (file)
@@ -429,6 +429,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
                if (this.contentTypeManager == null) {
                    logger.log(POILogger.WARN,
                            "Unable to call close() on a package that hasn't been fully opened yet");
+                       revert();
                    return;
                }
 
index 56536d238244c3b77d6b048076714888bb203b5b..632d2af262de5679ad5b40a12ebc2d005873fe14 100644 (file)
@@ -247,8 +247,11 @@ public final class ZipHelper {
         
         // Peek at the first few bytes to sanity check
         FileInputStream input = new FileInputStream(file);
-        verifyZipHeader(input);
-        input.close();
+        try {
+            verifyZipHeader(input);
+        } finally {
+            input.close();
+        }
 
         // Open as a proper zip file
         return new ZipSecureFile(file);