Author: tilman
Date: Tue Jun 25 10:40:24 2024
New Revision: 1918582

URL: http://svn.apache.org/viewvc?rev=1918582&view=rev
Log:
PDFBOX-5660: improve javadoc, avoid hypothetical memory leak (simplify future 
PR by Mykola Bohdiuk)

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

Modified: 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java?rev=1918582&r1=1918581&r2=1918582&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java 
(original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/GlyphTable.java 
Tue Jun 25 10:40:24 2024
@@ -80,7 +80,10 @@ public class GlyphTable extends TTFTable
         // we don't actually read the complete table here because it can 
contain tens of thousands of glyphs
         // cache the relevant part of the font data so that the data stream 
can be closed if it is no longer needed
         byte[] dataBytes = data.read((int) getLength());
-        this.data = new RandomAccessReadDataStream(new 
RandomAccessReadBuffer(dataBytes));
+        try (RandomAccessReadBuffer read = new 
RandomAccessReadBuffer(dataBytes))
+        {
+            this.data = new RandomAccessReadDataStream(read);
+        }
 
         // PDFBOX-5460: read hmtx table early to avoid deadlock if getGlyph() 
locks "data"
         // and then locks TrueTypeFont to read this table, while another thread

Modified: 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/RandomAccessReadDataStream.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/RandomAccessReadDataStream.java?rev=1918582&r1=1918581&r2=1918582&view=diff
==============================================================================
--- 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/RandomAccessReadDataStream.java
 (original)
+++ 
pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/RandomAccessReadDataStream.java
 Tue Jun 25 10:40:24 2024
@@ -36,7 +36,7 @@ class RandomAccessReadDataStream extends
     /**
      * Constructor.
      *
-     * @param randomAccessRead source to be read from
+     * @param randomAccessRead source to be read from. Caller should close it.
      *
      * @throws IOException If there is a problem reading the source data.
      */
@@ -56,7 +56,7 @@ class RandomAccessReadDataStream extends
     /**
      * Constructor.
      *
-     * @param inputStream source to be read from
+     * @param inputStream source to be read from. Caller should close it.
      *
      * @throws IOException If there is a problem reading the source data.
      */


Reply via email to