Commit ad73bbcd90bfac665f43f83131a4d7f913505350
1 parent
52539544
Change QPDF::reserveObjects to reserve indirect nulls to reserve foreign objects
Showing
2 changed files
with
11 additions
and
3 deletions
include/qpdf/QPDF.hh
| @@ -351,6 +351,8 @@ class QPDF | @@ -351,6 +351,8 @@ class QPDF | ||
| 351 | // QPDF with QPDFWriter if it has any reserved objects in it. | 351 | // QPDF with QPDFWriter if it has any reserved objects in it. |
| 352 | QPDF_DLL | 352 | QPDF_DLL |
| 353 | QPDFObjectHandle newReserved(); | 353 | QPDFObjectHandle newReserved(); |
| 354 | + QPDF_DLL | ||
| 355 | + QPDFObjectHandle newIndirectNull(); | ||
| 354 | 356 | ||
| 355 | // Install this object handle as an indirect object and return an indirect reference to it. | 357 | // Install this object handle as an indirect object and return an indirect reference to it. |
| 356 | QPDF_DLL | 358 | QPDF_DLL |
libqpdf/QPDF.cc
| @@ -1861,6 +1861,12 @@ QPDF::newReserved() | @@ -1861,6 +1861,12 @@ QPDF::newReserved() | ||
| 1861 | } | 1861 | } |
| 1862 | 1862 | ||
| 1863 | QPDFObjectHandle | 1863 | QPDFObjectHandle |
| 1864 | +QPDF::newIndirectNull() | ||
| 1865 | +{ | ||
| 1866 | + return makeIndirectFromQPDFObject(QPDF_Null::create()); | ||
| 1867 | +} | ||
| 1868 | + | ||
| 1869 | +QPDFObjectHandle | ||
| 1864 | QPDF::newStream() | 1870 | QPDF::newStream() |
| 1865 | { | 1871 | { |
| 1866 | return makeIndirectFromQPDFObject( | 1872 | return makeIndirectFromQPDFObject( |
| @@ -2015,8 +2021,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign) | @@ -2015,8 +2021,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign) | ||
| 2015 | reserveObjects(foreign, obj_copier, true); | 2021 | reserveObjects(foreign, obj_copier, true); |
| 2016 | 2022 | ||
| 2017 | if (!obj_copier.visiting.empty()) { | 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 | // Copy any new objects and replace the reservations. | 2027 | // Copy any new objects and replace the reservations. |
| @@ -2071,7 +2076,8 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top) | @@ -2071,7 +2076,8 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top) | ||
| 2071 | QTC::TC("qpdf", "QPDF copy indirect"); | 2076 | QTC::TC("qpdf", "QPDF copy indirect"); |
| 2072 | if (obj_copier.object_map.count(foreign_og) == 0) { | 2077 | if (obj_copier.object_map.count(foreign_og) == 0) { |
| 2073 | obj_copier.to_copy.push_back(foreign); | 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 |