mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Merge #9743: Fix several potential issues found by sanitizers
1d31093
fix tsan: utiltime race on nMockTime (Pieter Wuille)321bbc2
fix ubsan: bitcoin-tx: not initialize context before IsFullyValid (Pieter Wuille) Tree-SHA512: 39ea83c6122f06339cd425deb236357694e84ce2e4e9c61c10b90a8909b6e42e8c7b76396175cdc4723ababd2fa4f935d48f8a469baf853c5a06d7b962a5c8dc
This commit is contained in:
commit
6fdb319165
@ -657,11 +657,13 @@ static void MutateTx(CMutableTransaction& tx, const std::string& command,
|
||||
MutateTxDelOutput(tx, commandVal);
|
||||
else if (command == "outaddr")
|
||||
MutateTxAddOutAddr(tx, commandVal);
|
||||
else if (command == "outpubkey")
|
||||
else if (command == "outpubkey") {
|
||||
if (!ecc) { ecc.reset(new Secp256k1Init()); }
|
||||
MutateTxAddOutPubKey(tx, commandVal);
|
||||
else if (command == "outmultisig")
|
||||
} else if (command == "outmultisig") {
|
||||
if (!ecc) { ecc.reset(new Secp256k1Init()); }
|
||||
MutateTxAddOutMultiSig(tx, commandVal);
|
||||
else if (command == "outscript")
|
||||
} else if (command == "outscript")
|
||||
MutateTxAddOutScript(tx, commandVal);
|
||||
else if (command == "outdata")
|
||||
MutateTxAddOutData(tx, commandVal);
|
||||
|
@ -9,14 +9,17 @@
|
||||
|
||||
#include "utiltime.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
static int64_t nMockTime = 0; //!< For unit testing
|
||||
static std::atomic<int64_t> nMockTime(0); //!< For unit testing
|
||||
|
||||
int64_t GetTime()
|
||||
{
|
||||
if (nMockTime) return nMockTime;
|
||||
int64_t mocktime = nMockTime.load(std::memory_order_relaxed);
|
||||
if (mocktime) return mocktime;
|
||||
|
||||
time_t now = time(NULL);
|
||||
assert(now > 0);
|
||||
@ -25,7 +28,7 @@ int64_t GetTime()
|
||||
|
||||
void SetMockTime(int64_t nMockTimeIn)
|
||||
{
|
||||
nMockTime = nMockTimeIn;
|
||||
nMockTime.store(nMockTimeIn, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
int64_t GetTimeMillis()
|
||||
@ -52,7 +55,8 @@ int64_t GetSystemTimeInSeconds()
|
||||
/** Return a time useful for the debug log */
|
||||
int64_t GetLogTimeMicros()
|
||||
{
|
||||
if (nMockTime) return nMockTime*1000000;
|
||||
int64_t mocktime = nMockTime.load(std::memory_order_relaxed);
|
||||
if (mocktime) return mocktime*1000000;
|
||||
|
||||
return GetTimeMicros();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user