diff options
Diffstat (limited to 'src/corelib/global/qrandom.cpp')
-rw-r--r-- | src/corelib/global/qrandom.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index d77ec8075a..9abb9ece7f 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -154,15 +154,19 @@ class SystemRandom { static QBasicAtomicInt s_fdp1; // "file descriptor plus 1" static int openDevice(); +#ifdef Q_CC_GNU + // If it's not GCC or GCC-like, then we'll leak the file descriptor + __attribute__((destructor)) +#endif + static void closeDevice(); SystemRandom() {} - ~SystemRandom(); public: enum { EfficientBufferFill = true }; static qssize_t fillBuffer(void *buffer, qssize_t count); }; QBasicAtomicInt SystemRandom::s_fdp1 = Q_BASIC_ATOMIC_INITIALIZER(0); -SystemRandom::~SystemRandom() +void SystemRandom::closeDevice() { int fd = s_fdp1.loadAcquire() - 1; if (fd >= 0) |