aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFWriter.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-04-02 23:58:19 +0200
committerJay Berkenbilt <ejb@ql.org>2020-04-03 18:16:24 +0200
commit70665cb381ab8e24d6713bc2a6899520d6097500 (patch)
tree4fea44841f2eb61812320c346c3bc134736b3fc1 /libqpdf/QPDFWriter.cc
parent38afdcea7b08226aa6cc12a8fcda93a6f35a0a18 (diff)
downloadqpdf-70665cb381ab8e24d6713bc2a6899520d6097500.tar.zst
Internally use unsafeShallowCopy where we can
Diffstat (limited to 'libqpdf/QPDFWriter.cc')
-rw-r--r--libqpdf/QPDFWriter.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index 5f97117d..cdab9db1 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -1502,12 +1502,14 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
else if (object.isDictionary())
{
// Make a shallow copy of this object so we can modify it
- // safely without affecting the original. This code makes
+ // safely without affecting the original. This code makes
// assumptions about things that are made true in
// prepareFileForWrite, such as that certain things are direct
// objects so that replacing them doesn't leave unreferenced
- // objects in the output.
- object = object.shallowCopy();
+ // objects in the output. We can use unsafeShallowCopy here
+ // because we are all we are doing is removing or replacing
+ // top-level keys.
+ object = object.unsafeShallowCopy();
// Handle special cases for specific dictionaries.
@@ -2413,7 +2415,7 @@ QPDFWriter::getTrimmedTrailer()
// Remove keys from the trailer that necessarily have to be
// replaced when writing the file.
- QPDFObjectHandle trailer = this->m->pdf.getTrailer().shallowCopy();
+ QPDFObjectHandle trailer = this->m->pdf.getTrailer().unsafeShallowCopy();
// Remove encryption keys
trailer.removeKey("/ID");