This is an automated email from the ASF dual-hosted git repository.
tilman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pdfbox-jbig2.git
The following commit(s) were added to refs/heads/master by this push:
new 627cbd8 PDFBOX-6147: expect page 1; refactor
627cbd8 is described below
commit 627cbd8a0ebe180f247fce00b48e4ff449a0c22c
Author: Tilman Hausherr <[email protected]>
AuthorDate: Thu Jan 15 12:31:45 2026 +0100
PDFBOX-6147: expect page 1; refactor
---
src/main/java/org/apache/pdfbox/jbig2/JBIG2Document.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/pdfbox/jbig2/JBIG2Document.java
b/src/main/java/org/apache/pdfbox/jbig2/JBIG2Document.java
index f2dfa1f..874450a 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/JBIG2Document.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/JBIG2Document.java
@@ -188,8 +188,6 @@ class JBIG2Document
globalSegments = new JBIG2Globals();
}
- JBIG2Page page = null;
-
/*
* If organisation type is random-access: walk through the segment
headers until EOF segment appears (specified
* with segment number 51)
@@ -204,7 +202,7 @@ class JBIG2Document
if (associatedPage != 0)
{
- page = getPage(associatedPage);
+ JBIG2Page page = getPage(associatedPage);
if (page == null)
{
page = new JBIG2Page(this, associatedPage);
@@ -227,6 +225,13 @@ class JBIG2Document
}
}
+ // PDFBOX-6147: abort if first page isn't 1, however
+ // a purely empty document is valid when calling "new
JBIG2Document(globals)"
+ if (!pages.isEmpty() && pages.get(1) == null)
+ {
+ throw new IOException("Page 1 missing");
+ }
+
/*
* Random organization: segment headers are finished. Data part starts
and the offset can be set.
*/