aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFPageObjectHelper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libqpdf/QPDFPageObjectHelper.cc')
-rw-r--r--libqpdf/QPDFPageObjectHelper.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc
index b4e6a13a..a6773e70 100644
--- a/libqpdf/QPDFPageObjectHelper.cc
+++ b/libqpdf/QPDFPageObjectHelper.cc
@@ -597,8 +597,7 @@ QPDFPageObjectHelper::removeUnreferencedResourcesHelper(
for (auto const& iter : to_filter) {
QPDFObjectHandle dict = resources.getKey(iter);
if (dict.isDictionary()) {
- dict = dict.shallowCopy();
- resources.replaceKey(iter, dict);
+ dict = resources.replaceKeyAndGet(iter, dict.shallowCopy());
rdicts.push_back(dict);
auto keys = dict.getKeys();
known_names.insert(keys.begin(), keys.end());
@@ -1113,8 +1112,8 @@ QPDFPageObjectHelper::copyAnnotations(
afdh->addAndRenameFormFields(new_fields);
auto annots = this->oh.getKey("/Annots");
if (!annots.isArray()) {
- annots = QPDFObjectHandle::newArray();
- this->oh.replaceKey("/Annots", annots);
+ annots =
+ this->oh.replaceKeyAndGet("/Annots", QPDFObjectHandle::newArray());
}
for (auto const& annot : new_annots) {
annots.appendItem(annot);