aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorDean Scarff <deanscarff@google.com>2020-04-04 03:48:25 +0200
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2020-04-04 14:29:28 +0200
commitc5c1a028cdd3cf345046c46963fb0fdacfb2c33c (patch)
tree3f5bf8810fce9519e6de6b356ebbc20296fc483c /libqpdf
parent2100b4ce152e9c70b3ce8760112d5a24ead4e52d (diff)
downloadqpdf-c5c1a028cdd3cf345046c46963fb0fdacfb2c33c.tar.zst
Use deterministic assignments for unique_id
Fixes qpdf/qpdf#419
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDF.cc6
1 files changed, 3 insertions, 3 deletions
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 <qpdf/qpdf-config.h> // include first for large file support
#include <qpdf/QPDF.hh>
+#include <atomic>
#include <vector>
#include <map>
#include <algorithm>
@@ -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<unsigned long>(QUtil::get_current_time());
- m->unique_id <<= 32;
- m->unique_id |= static_cast<unsigned long>(QUtil::random());
+ static std::atomic<unsigned long long> unique_id{0};
+ m->unique_id = unique_id.fetch_add(1ULL);
}
QPDF::~QPDF()