pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1704750 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
Date Tue, 22 Sep 2015 23:15:55 GMT
Author: tilman
Date: Tue Sep 22 23:15:52 2015
New Revision: 1704750

URL: http://svn.apache.org/viewvc?rev=1704750&view=rev
Log:
PDFBOX-2986: avoid potential resource leak when exception

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java?rev=1704750&r1=1704749&r2=1704750&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFParser.java Tue Sep 22 23:15:52
2015
@@ -81,7 +81,17 @@ public class TTFParser
      */
     public TrueTypeFont parse(File ttfFile) throws IOException
     {
-        return parse(new RAFDataStream(ttfFile, "r"));
+        RAFDataStream raf = new RAFDataStream(ttfFile, "r");
+        try
+        {
+            return parse(raf);
+        }
+        catch (IOException ex)
+        {
+            // close only on error (file is still being accessed later)
+            raf.close();
+            throw ex;
+        }
     }
 
     /**



Mime
View raw message