You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2023/05/23 06:26:39 UTC
svn commit: r1910009 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
Author: lehmi
Date: Tue May 23 06:26:39 2023
New Revision: 1910009
URL: http://svn.apache.org/viewvc?rev=1910009&view=rev
Log: (empty)
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java?rev=1910009&r1=1910008&r2=1910009&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java Tue May 23 06:26:39 2023
@@ -138,6 +138,7 @@ public class PDFStreamParser extends Bas
skipSpaces();
if (seqSource.isEOF())
{
+ close();
return null;
}
char c = (char) seqSource.peek();
@@ -163,6 +164,7 @@ public class PDFStreamParser extends Bas
{
LOG.warn("Stop reading invalid dictionary from content stream at offset "
+ seqSource.getPosition());
+ close();
return null;
}
}
@@ -180,6 +182,7 @@ public class PDFStreamParser extends Bas
{
LOG.warn("Stop reading invalid array from content stream at offset "
+ seqSource.getPosition());
+ close();
return null;
}
case '(':
@@ -293,8 +296,10 @@ public class PDFStreamParser extends Bas
String id = Character.toString((char) seqSource.read()) + (char) seqSource.read();
if (!id.equals(OperatorName.BEGIN_INLINE_IMAGE_DATA))
{
+ long currentPosition = seqSource.getPosition();
+ close();
throw new IOException( "Error: Expected operator 'ID' actual='" + id +
- "' at stream offset " + seqSource.getPosition());
+ "' at stream offset " + currentPosition);
}
ByteArrayOutputStream imageData = new ByteArrayOutputStream();
if( isWhitespace() )
@@ -469,4 +474,17 @@ public class PDFStreamParser extends Bas
{
return isSpaceOrReturn( seqSource.peek() );
}
+
+ /**
+ * Close the underlying resource.
+ *
+ * @throws IOException if something went wrong
+ */
+ public void close() throws IOException
+ {
+ if (seqSource != null)
+ {
+ seqSource.close();
+ }
+ }
}