From c5c1a028cdd3cf345046c46963fb0fdacfb2c33c Mon Sep 17 00:00:00 2001 From: Dean Scarff Date: Sat, 4 Apr 2020 12:48:25 +1100 Subject: Use deterministic assignments for unique_id Fixes qpdf/qpdf#419 --- libqpdf/QPDF.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libqpdf/QPDF.cc') diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index bbe8f31c..3177d38b 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1,6 +1,7 @@ #include // include first for large file support #include +#include #include #include #include @@ -172,9 +173,8 @@ QPDF::QPDF() : // 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(QUtil::get_current_time()); - m->unique_id <<= 32; - m->unique_id |= static_cast(QUtil::random()); + static std::atomic unique_id{0}; + m->unique_id = unique_id.fetch_add(1ULL); } QPDF::~QPDF() -- cgit v1.2.3-54-g00ecf