File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
main/java/com/itextpdf/core/pdf
java/com/itextpdf/core/pdf
resources/com/itextpdf/core/pdf/PdfReaderTest Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -936,7 +936,7 @@ protected PdfDictionary readXrefSection() throws IOException {
936
936
}
937
937
PdfDictionary trailer = (PdfDictionary ) readObject (false );
938
938
PdfNumber xrefSize = (PdfNumber ) trailer .get (PdfName .Size );
939
- if (xrefSize == null || xrefSize .getIntValue () != end ) {
939
+ if (xrefSize == null || ( xrefSize .getIntValue () != end && end > 0 ) ) {
940
940
throw new PdfException (PdfException .InvalidXrefSection );
941
941
}
942
942
Original file line number Diff line number Diff line change @@ -1472,6 +1472,28 @@ public void pdfVersionTest() throws IOException {
1472
1472
pdfDoc .close ();
1473
1473
}
1474
1474
1475
+ @ Test
1476
+ public void zeroUpdateTest () throws IOException {
1477
+ String filename = sourceFolder + "stationery.pdf" ;
1478
+
1479
+ FileInputStream fis = new FileInputStream (filename );
1480
+ PdfReader reader = new PdfReader (fis );
1481
+ PdfDocument pdfDoc = new PdfDocument (reader );
1482
+
1483
+ // Test such construction:
1484
+ // xref
1485
+ // 0 0
1486
+ // trailer
1487
+ // <</Size 27/Root 1 0 R/Info 12 0 R//Prev 245232/XRefStm 244927>>
1488
+ // startxref
1489
+
1490
+ Assert .assertFalse (reader .hasFixedXref ());
1491
+ Assert .assertFalse (reader .hasRebuiltXref ());
1492
+
1493
+ pdfDoc .close ();
1494
+ }
1495
+
1496
+
1475
1497
private boolean objectTypeEqualTo (PdfObject object , PdfName type ) {
1476
1498
PdfName objectType = ((PdfDictionary )object ).getAsName (PdfName .Type );
1477
1499
return type .equals (objectType );
You can’t perform that action at this time.
0 commit comments