Skip to content

Commit c4277da

Browse files
committed
fix: don't clobber objects that are overridden in a trailer when reading compressed objects
1 parent 3a1cbf9 commit c4277da

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

PdfSharpCore/Pdf.IO/PdfReader.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,13 @@ public static PdfDocument Open(Stream stream, string password, PdfDocumentOpenMo
499499
// Is type xref to compressed object?
500500
if (item.Type == 2)
501501
{
502+
if (document._irefTable.ObjectTable.TryGetValue(new PdfObjectID(idx2), out var irefToRead) && irefToRead.Position > 0)
503+
{
504+
// The object has been overridden by a trailer with a specific position.
505+
// Don't read from compressed objects. Continue on later to "read all indirect objects"
506+
continue;
507+
}
508+
502509
PdfReference irefNew = parser.ReadCompressedObject(new PdfObjectID((int)item.Field2),
503510
(int)item.Field3);
504511
Debug.Assert(document._irefTable.Contains(iref.ObjectID));

0 commit comments

Comments
 (0)