mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2026-01-31 15:37:55 +01:00
When a duplicate object is seen in an xref stream, only replace the object if it has a higher generation number (Issue #155)
This commit is contained in:
@@ -24,6 +24,7 @@ v1.6.2 - YYYY-MM-DD
|
||||
- Added missing range checks to `pdfioArrayCopy` and `pdfioDictCopy`.
|
||||
- Refactored PDF encryption code to fix unlocking with certain files.
|
||||
- Improved xref table loop detection (Issue #148)
|
||||
- Changed how duplicate objects are handled in PDF files (Issue #155)
|
||||
- Fixed xref reconstruction for objects lacking a `Type` value.
|
||||
- Fixed `pdfioPageOpenStream` for indirect `Contents` arrays.
|
||||
- Fixed an error propagation bug when reading too-long values (Issue #146)
|
||||
|
||||
28
pdfio-file.c
28
pdfio-file.c
@@ -2236,20 +2236,26 @@ load_xref(
|
||||
// Create a placeholder for the object in memory...
|
||||
if ((current = pdfioFileFindObj(pdf, (size_t)number)) != NULL)
|
||||
{
|
||||
PDFIO_DEBUG("load_xref: existing object, prev offset=%u\n", (unsigned)current->offset);
|
||||
PDFIO_DEBUG("load_xref: existing object, prev offset=%u, generation=%u, new generation=%u\n", (unsigned)current->offset, (unsigned)current->generation, (unsigned)generation);
|
||||
|
||||
if (w[0] == 0 || buffer[0] == 1)
|
||||
if (generation > current->generation)
|
||||
{
|
||||
// Location of object...
|
||||
current->offset = (off_t)offset;
|
||||
}
|
||||
else if (number != offset)
|
||||
{
|
||||
// Object is part of a stream, offset is the object number...
|
||||
current->offset = 0;
|
||||
}
|
||||
// Newer version of an existing object - update the references...
|
||||
current->generation = generation;
|
||||
|
||||
PDFIO_DEBUG("load_xref: new offset=%u\n", (unsigned)current->offset);
|
||||
if (w[0] == 0 || buffer[0] == 1)
|
||||
{
|
||||
// Location of object...
|
||||
current->offset = (off_t)offset;
|
||||
}
|
||||
else if (number != offset)
|
||||
{
|
||||
// Object is part of a stream, offset is the object number...
|
||||
current->offset = 0;
|
||||
}
|
||||
|
||||
PDFIO_DEBUG("load_xref: new offset=%u\n", (unsigned)current->offset);
|
||||
}
|
||||
}
|
||||
|
||||
if (w[0] > 0 && buffer[0] == 2)
|
||||
|
||||
Reference in New Issue
Block a user