Skip to content

Commit

Permalink
Merge pull request bitshares#211 from xloem/static-segfault
Browse files Browse the repository at this point in the history
fix for static initialization order segfault
  • Loading branch information
abitmore authored Sep 28, 2020
2 parents 781c9cd + 95cc8ce commit 2cb7bf1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/crypto/openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ namespace fc
{
struct openssl_scope
{
static path _configurationFilePath;
static path & _configurationFilePath()
{
static path orderindependentstorage;
return orderindependentstorage;
}
openssl_scope()
{
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();

const boost::filesystem::path& boostPath = _configurationFilePath;
const boost::filesystem::path& boostPath = _configurationFilePath();
if(boostPath.empty() == false)
{
std::string varSetting("OPENSSL_CONF=");
varSetting += _configurationFilePath.to_native_ansi_path();
varSetting += _configurationFilePath().to_native_ansi_path();
#if defined(WIN32)
_putenv((char*)varSetting.c_str());
#else
Expand Down Expand Up @@ -51,11 +55,9 @@ namespace fc
}
};

path openssl_scope::_configurationFilePath;

void store_configuration_path(const path& filePath)
{
openssl_scope::_configurationFilePath = filePath;
openssl_scope::_configurationFilePath() = filePath;
}

int init_openssl()
Expand Down

0 comments on commit 2cb7bf1

Please sign in to comment.