Skip to content

Commit

Permalink
Use secure allocator for RNG state
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Jan 17, 2019
1 parent cddb31b commit f2e60ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <chrono>
#include <thread>

#include <support/allocators/secure.h>

#ifndef WIN32
#include <fcntl.h>
#include <sys/time.h>
Expand Down Expand Up @@ -351,8 +353,8 @@ RNGState& GetRNGState() noexcept
{
// This C++11 idiom relies on the guarantee that static variable are initialized
// on first call, even when multiple parallel calls are permitted.
static std::unique_ptr<RNGState> g_rng{new RNGState()};
return *g_rng;
static std::vector<RNGState, secure_allocator<RNGState>> g_rng(1);
return g_rng[0];
}
}

Expand Down

0 comments on commit f2e60ca

Please sign in to comment.