Browse Source

More defensive checking of value for seed height.

main
kevacoin 2 years ago
parent
commit
9c4c306499
  1. 2
      configure.ac
  2. 9
      src/primitives/block.cpp

2
configure.ac

@ -280,7 +280,7 @@ AX_CHECK_COMPILE_FLAG([-maes],[[AES_CFLAGS="-maes"]],[[AES_CFLAGS="no"]],[[$CXXF @@ -280,7 +280,7 @@ AX_CHECK_COMPILE_FLAG([-maes],[[AES_CFLAGS="-maes"]],[[AES_CFLAGS="no"]],[[$CXXF
if test x$AES_CFLAGS = xno; then
AC_MSG_ERROR("Compiler does not support -maes which is required by Cryptonight.")
fi
CFLAGS="$CXXFLAGS $AES_CFLAGS"
CFLAGS="$CFLAGS $AES_CFLAGS"
TEMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $SSE42_CXXFLAGS"

9
src/primitives/block.cpp

@ -20,13 +20,16 @@ extern "C" void cn_fast_hash(const void *data, size_t length, char *hash); @@ -20,13 +20,16 @@ extern "C" void cn_fast_hash(const void *data, size_t length, char *hash);
static void cn_get_block_hash_by_height(uint64_t seed_height, char cnHash[32])
{
CBlockIndex* pblockindex = chainActive[seed_height];
if (pblockindex == NULL) {
if (pblockindex == nullptr) {
// This will happen during initial block downloading, or when we
// are out of sync by more than at least SEEDHASH_EPOCH_BLOCKS blocks.
LOCK(cs_main);
pblockindex = mapBlockSeedHeight.find(seed_height)->second;
std::map<uint64_t, CBlockIndex*>::iterator iter = mapBlockSeedHeight.find(seed_height);
if (iter != mapBlockSeedHeight.end()) {
pblockindex = iter->second;
}
}
if (pblockindex == NULL) {
if (pblockindex == nullptr) {
return;
}
uint256 blockHash = pblockindex->GetBlockHash();

Loading…
Cancel
Save