Commit ad73bbcd90bfac665f43f83131a4d7f913505350

Authored by m-holger
1 parent 52539544

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

include/qpdf/QPDF.hh
... ... @@ -351,6 +351,8 @@ class QPDF
351 351 // QPDF with QPDFWriter if it has any reserved objects in it.
352 352 QPDF_DLL
353 353 QPDFObjectHandle newReserved();
  354 + QPDF_DLL
  355 + QPDFObjectHandle newIndirectNull();
354 356  
355 357 // Install this object handle as an indirect object and return an indirect reference to it.
356 358 QPDF_DLL
... ...
libqpdf/QPDF.cc
... ... @@ -1861,6 +1861,12 @@ QPDF::newReserved()
1861 1861 }
1862 1862  
1863 1863 QPDFObjectHandle
  1864 +QPDF::newIndirectNull()
  1865 +{
  1866 + return makeIndirectFromQPDFObject(QPDF_Null::create());
  1867 +}
  1868 +
  1869 +QPDFObjectHandle
1864 1870 QPDF::newStream()
1865 1871 {
1866 1872 return makeIndirectFromQPDFObject(
... ... @@ -2015,8 +2021,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
2015 2021 reserveObjects(foreign, obj_copier, true);
2016 2022  
2017 2023 if (!obj_copier.visiting.empty()) {
2018   - throw std::logic_error("obj_copier.visiting is not empty"
2019   - " after reserving objects");
  2024 + throw std::logic_error("obj_copier.visiting is not empty after reserving objects");
2020 2025 }
2021 2026  
2022 2027 // Copy any new objects and replace the reservations.
... ... @@ -2071,7 +2076,8 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top)
2071 2076 QTC::TC("qpdf", "QPDF copy indirect");
2072 2077 if (obj_copier.object_map.count(foreign_og) == 0) {
2073 2078 obj_copier.to_copy.push_back(foreign);
2074   - obj_copier.object_map[foreign_og] = foreign.isStream() ? newStream() : newReserved();
  2079 + obj_copier.object_map[foreign_og] =
  2080 + foreign.isStream() ? newStream() : newIndirectNull();
2075 2081 }
2076 2082 }
2077 2083  
... ...