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:
Eliot Jones
2020-01-07 11:47:21 +00:00
parent 0b048fde57
commit 5114b2da2c

View File

@@ -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;
}
}