2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-01-22 22:58:33 +00:00

Change QPDF::reserveObjects to reserve indirect nulls to reserve foreign objects

This commit is contained in:
m-holger 2023-08-25 13:28:48 +01:00
parent 52539544c4
commit ad73bbcd90
2 changed files with 11 additions and 3 deletions

View File

@ -351,6 +351,8 @@ class QPDF
// QPDF with QPDFWriter if it has any reserved objects in it.
QPDF_DLL
QPDFObjectHandle newReserved();
QPDF_DLL
QPDFObjectHandle newIndirectNull();
// Install this object handle as an indirect object and return an indirect reference to it.
QPDF_DLL

View File

@ -1860,6 +1860,12 @@ QPDF::newReserved()
return makeIndirectFromQPDFObject(QPDF_Reserved::create());
}
QPDFObjectHandle
QPDF::newIndirectNull()
{
return makeIndirectFromQPDFObject(QPDF_Null::create());
}
QPDFObjectHandle
QPDF::newStream()
{
@ -2015,8 +2021,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
reserveObjects(foreign, obj_copier, true);
if (!obj_copier.visiting.empty()) {
throw std::logic_error("obj_copier.visiting is not empty"
" after reserving objects");
throw std::logic_error("obj_copier.visiting is not empty after reserving objects");
}
// Copy any new objects and replace the reservations.
@ -2071,7 +2076,8 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top)
QTC::TC("qpdf", "QPDF copy indirect");
if (obj_copier.object_map.count(foreign_og) == 0) {
obj_copier.to_copy.push_back(foreign);
obj_copier.object_map[foreign_og] = foreign.isStream() ? newStream() : newReserved();
obj_copier.object_map[foreign_og] =
foreign.isStream() ? newStream() : newIndirectNull();
}
}