diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-01-06 16:07:23 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-01-07 06:11:15 +0100 |
commit | 7588cac2957f66c6f0e3f5fb5b691ecbb8f3e0b2 (patch) | |
tree | 70f7fbac4d9f5ffc285460b2c01d4c0a33bae91b /libqpdf | |
parent | e27ac682e00be12e9c420c26c218ee2a01fbf232 (diff) | |
download | qpdf-7588cac2957f66c6f0e3f5fb5b691ecbb8f3e0b2.tar.zst |
Create an application-scope unique ID for each QPDF object
Use this instead of QPDF* as a map key for object_copiers.
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDF.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 6d8f4fae..813775a2 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -89,6 +89,7 @@ QPDF::EncryptionParameters::EncryptionParameters() : } QPDF::Members::Members() : + unique_id(0), provided_password_is_hex_key(false), ignore_xref_streams(false), suppress_warnings(false), @@ -113,6 +114,12 @@ QPDF::QPDF() : m(new Members()) { m->tokenizer.allowEOF(); + // Generate a unique ID. It just has to be unique among all QPDF + // objects allocated throughout the lifetime of this running + // application. + m->unique_id = static_cast<unsigned long>(QUtil::get_current_time()); + m->unique_id <<= 32; + m->unique_id |= static_cast<unsigned long>(QUtil::random()); } QPDF::~QPDF() @@ -2103,7 +2110,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign, bool allow_page) "QPDF::copyForeign called with object from this QPDF"); } - ObjCopier& obj_copier = this->m->object_copiers[other]; + ObjCopier& obj_copier = this->m->object_copiers[other->m->unique_id]; if (! obj_copier.visiting.empty()) { throw std::logic_error("obj_copier.visiting is not empty" |