2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-01 03:12:29 +00:00

Refactor test for /Pages object in QPDF::copyForeignObject

Test for missing object before accessing obj_copier.object_map.
This commit is contained in:
m-holger 2023-09-03 11:03:24 +01:00
parent ca79fcb26e
commit b0c3ea2bb6
2 changed files with 7 additions and 7 deletions

View File

@ -2034,13 +2034,13 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
} }
obj_copier.to_copy.clear(); obj_copier.to_copy.clear();
auto& result = obj_copier.object_map[foreign.getObjGen()]; auto og = foreign.getObjGen();
if (!result.isInitialized()) { if (!obj_copier.object_map.count(og)) {
result = QPDFObjectHandle::newNull(); warn(damagedPDF("unexpected reference to /Pages object while copying foreign object; "
warn(damagedPDF("Unexpected reference to /Pages object while copying foreign object. " "replacing with null"));
"Replacing with Null object.")); return QPDFObjectHandle::newNull();
} }
return result; return obj_copier.object_map[foreign.getObjGen()];
} }
void void

View File

@ -1,2 +1,2 @@
WARNING: minimal.pdf (object 6 0, offset 556): Unexpected reference to /Pages object while copying foreign object. Replacing with Null object. WARNING: minimal.pdf (object 6 0, offset 556): unexpected reference to /Pages object while copying foreign object; replacing with null
test 25 done test 25 done