Return-Path: X-Original-To: apmail-pdfbox-commits-archive@www.apache.org Delivered-To: apmail-pdfbox-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EC68817CF6 for ; Tue, 22 Sep 2015 19:11:26 +0000 (UTC) Received: (qmail 9705 invoked by uid 500); 22 Sep 2015 19:11:26 -0000 Delivered-To: apmail-pdfbox-commits-archive@pdfbox.apache.org Received: (qmail 9682 invoked by uid 500); 22 Sep 2015 19:11:26 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 9673 invoked by uid 99); 22 Sep 2015 19:11:26 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Sep 2015 19:11:26 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 4F23E180997 for ; Tue, 22 Sep 2015 19:11:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.5 X-Spam-Level: *** X-Spam-Status: No, score=3.5 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RDNS_NONE=2.5] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id UJW0P3HFJVcU for ; Tue, 22 Sep 2015 19:11:25 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (unknown [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id 5D24844165 for ; Tue, 22 Sep 2015 19:11:25 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E21F6E043F for ; Tue, 22 Sep 2015 19:11:24 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id E0E9E3A01DC for ; Tue, 22 Sep 2015 19:11:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150922191124.E0E9E3A01DC@svn01-us-west.apache.org> 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; } /**