Skip to content

Commit

Permalink
Clear devNetParams and mimic behavior of other param types (#2367)
Browse files Browse the repository at this point in the history
* Clear devNetParams and mimic behavior of other param types

Mainnet, testnet and regtest params are global and thus zero initialized,
we should mimic the same for devnet params.

Not doing so results in all kinds of issues on devnet.

* Remove unnecessary <string.h> includein chainparamsbase.cpp
  • Loading branch information
codablock authored Oct 25, 2018
1 parent fdfb077 commit e3046ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,9 @@ CChainParams& Params(const std::string& chain)
void SelectParams(const std::string& network)
{
if (network == CBaseChainParams::DEVNET) {
devNetParams = new CDevNetParams();
devNetParams = (CDevNetParams*)new uint8_t[sizeof(CDevNetParams)];
memset(devNetParams, 0, sizeof(CDevNetParams));
new (devNetParams) CDevNetParams();
}

SelectBaseParams(network);
Expand Down
5 changes: 4 additions & 1 deletion src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ void SelectBaseParams(const std::string& chain)
if (chain == CBaseChainParams::DEVNET) {
std::string devNetName = GetDevNetName();
assert(!devNetName.empty());
devNetParams = new CBaseDevNetParams(devNetName);

devNetParams = (CBaseDevNetParams*)new uint8_t[sizeof(CBaseDevNetParams)];
memset(devNetParams, 0, sizeof(CBaseDevNetParams));
new (devNetParams) CBaseDevNetParams(devNetName);
}

pCurrentBaseParams = &BaseParams(chain);
Expand Down

0 comments on commit e3046ad

Please sign in to comment.