From ddd78c1b7f53f09710431d58cd94659271f325cc Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 21 Jun 2018 20:33:38 -0400 Subject: Fix QPDFObjectHandle::shallowCopy It's not really a shallow copy. It just doesn't cross indirect object boundaries. The old implementation had a bug that would cause multiple shallow copies of the same object to share memory, which was not the intention. --- include/qpdf/QPDFObjectHandle.hh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 868b5c07..6e45b5fd 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -514,10 +514,11 @@ class QPDFObjectHandle QPDF_DLL QPDF* getOwningQPDF(); - // Create a shallow copy of an object as a direct object. Since - // this is a shallow copy, for dictionaries and arrays, any keys - // or items that were indirect objects will still be indirect - // objects that point to the same place. + // Create a shallow of an object as a direct object, but do not + // traverse across indirect object boundaries. That means that, + // for dictionaries and arrays, any keys or items that were + // indirect objects will still be indirect objects that point to + // the same place. QPDF_DLL QPDFObjectHandle shallowCopy(); @@ -880,7 +881,7 @@ class QPDFObjectHandle void objectWarning(std::string const& warning); void assertType(char const* type_name, bool istype); void dereference(); - void makeDirectInternal(std::set& visited); + void copyObject(std::set& visited, bool cross_indirect); void releaseResolved(); static void setObjectDescriptionFromInput( QPDFObjectHandle, QPDF*, std::string const&, -- cgit v1.2.3-54-g00ecf