pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1704693 - /pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/AbstractTTFParser.java
Date Tue, 22 Sep 2015 19:11:24 GMT
Author: tilman
Date: Tue Sep 22 19:11:22 2015
New Revision: 1704693

URL: http://svn.apache.org/viewvc?rev=1704693&view=rev
Log:
PDFBOX-2986: avoid potential resource leak pointed out by Tim Allison

Modified:
    pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/AbstractTTFParser.java

Modified: pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/AbstractTTFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/AbstractTTFParser.java?rev=1704693&r1=1704692&r2=1704693&view=diff
==============================================================================
--- pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/AbstractTTFParser.java
(original)
+++ pdfbox/branches/1.8/fontbox/src/main/java/org/apache/fontbox/ttf/AbstractTTFParser.java
Tue Sep 22 19:11:22 2015
@@ -21,7 +21,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Iterator;
 
-abstract class AbstractTTFParser {
+abstract class AbstractTTFParser
+{
 	
     protected boolean isEmbedded = false;
     protected boolean parseOnDemandOnly = false;
@@ -32,7 +33,7 @@ abstract class AbstractTTFParser {
      * @param fontIsEmbedded indicates whether the font is embedded or not.
      * 
      */
-    public AbstractTTFParser(boolean fontIsEmbedded)
+    AbstractTTFParser(boolean fontIsEmbedded)
     {
         this(fontIsEmbedded, false);
     }
@@ -43,7 +44,7 @@ abstract class AbstractTTFParser {
      * @param fontIsEmbedded indicates whether the font is embedded or not.
      * @param parseOnDemand indicates whether the tables of the font should be parsed on
demand only or not.
      */
-    public AbstractTTFParser(boolean fontIsEmbedded, boolean parseOnDemand)
+    AbstractTTFParser(boolean fontIsEmbedded, boolean parseOnDemand)
     {
         isEmbedded = fontIsEmbedded;
         parseOnDemandOnly = parseOnDemand;
@@ -57,8 +58,7 @@ abstract class AbstractTTFParser {
      */
     public TrueTypeFont parseTTF( String ttfFile ) throws IOException
     {
-        RAFDataStream raf = new RAFDataStream( ttfFile, "r" );
-        return parseTTF( raf );
+        return parseTTF(new File(ttfFile));
     }
     
     /**
@@ -69,8 +69,17 @@ abstract class AbstractTTFParser {
      */
     public TrueTypeFont parseTTF( File ttfFile ) throws IOException
     {
-        RAFDataStream raf = new RAFDataStream( ttfFile, "r" );
-        return parseTTF( raf );
+        TrueTypeFont ttf = null;
+        RAFDataStream raf = new RAFDataStream(ttfFile, "r");
+        try
+        {
+            ttf = parseTTF(raf);
+        }
+        finally
+        {
+            raf.close();
+        }
+        return ttf;
     }
     
     /**



Mime
View raw message