Skip to content

Commit f2e60ca

Browse files
committed
Use secure allocator for RNG state
1 parent cddb31b commit f2e60ca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/random.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <chrono>
2020
#include <thread>
2121

22+
#include <support/allocators/secure.h>
23+
2224
#ifndef WIN32
2325
#include <fcntl.h>
2426
#include <sys/time.h>
@@ -351,8 +353,8 @@ RNGState& GetRNGState() noexcept
351353
{
352354
// This C++11 idiom relies on the guarantee that static variable are initialized
353355
// on first call, even when multiple parallel calls are permitted.
354-
static std::unique_ptr<RNGState> g_rng{new RNGState()};
355-
return *g_rng;
356+
static std::vector<RNGState, secure_allocator<RNGState>> g_rng(1);
357+
return g_rng[0];
356358
}
357359
}
358360

0 commit comments

Comments
 (0)