mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
fix: read item out of array blockinfo
in miner tests (#5084)
This array contains 119 items and all of them are used. But during test created one extra block that also need `blockinfo`. It is UB and trigger address sanitizer.
This commit is contained in:
parent
46b312381d
commit
e7bd9eb524
@ -88,6 +88,7 @@ constexpr static struct {
|
||||
{0, 0x40045af7}, {0, 0x6000df7a}, {0, 0xe00131a1}, {0, 0x40021386},
|
||||
{0, 0xa00891b5}, {0, 0x60007854}, {0, 0x60021730}
|
||||
};
|
||||
constexpr static size_t blockinfo_size = sizeof(blockinfo) / sizeof(blockinfo[0]);
|
||||
|
||||
static CBlockIndex CreateBlockIndex(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
@ -230,7 +231,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
std::vector<CTransactionRef> txFirst;
|
||||
|
||||
auto createAndProcessEmptyBlock = [&]() {
|
||||
int i = ::ChainActive().Height();
|
||||
int i = ::ChainActive().Height() % blockinfo_size;
|
||||
CBlock *pblock = &pemptyblocktemplate->block; // pointer for convenience
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
Loading…
Reference in New Issue
Block a user