Skip to content

Commit 751e970

Browse files
committed
PDFBOX-5283: ignore dublicate object keys when correcting xRefs
1 parent 4896c6f commit 751e970

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,13 @@ private Map<COSObjectKey, Long> bfSearchForObjects() throws IOException
13201320
if (lastObjOffset > 0)
13211321
{
13221322
// add the former object ID only if there was a subsequent object ID
1323-
bfCOSObjectKeyOffsets.put(
1324-
new COSObjectKey(lastObjectId, lastGenID), lastObjOffset);
1323+
COSObjectKey objectKey = new COSObjectKey(lastObjectId, lastGenID);
1324+
if(!bfCOSObjectKeyOffsets.containsKey(objectKey)) {
1325+
bfCOSObjectKeyOffsets.put(objectKey, lastObjOffset);
1326+
} else {
1327+
LOG.debug("Ignoring duplicate object key (" + objectKey
1328+
+ ")");
1329+
}
13251330
}
13261331
lastObjectId = objectId;
13271332
lastGenID = genID;

0 commit comments

Comments
 (0)