mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-21 04:17:57 +08:00
avoid overwriting cache for valid objects
some objects may be defined in more than one stream. parsing both streams would overwrite the object in the cache. to prevent this we avoid overwriting the existing object in the cache if it has the expected offset from the cross reference table.
This commit is contained in:
@@ -90,6 +90,16 @@
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
|
||||
if (cache.TryGetValue(objectToken.Number, out var existing))
|
||||
{
|
||||
var crossReference = crossReferenceTable();
|
||||
if (crossReference != null && crossReference.ObjectOffsets.TryGetValue(objectToken.Number, out var expected)
|
||||
&& existing.Position == expected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
cache[objectToken.Number] = objectToken;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user