Skip to content

Commit

Permalink
Revert "Test Fix Uninitialized Pointer"
Browse files Browse the repository at this point in the history
This reverts commit 62961e0.
  • Loading branch information
fgabelmannjr committed Jan 25, 2025
1 parent 9bcb203 commit 6e2cf3d
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3101,24 +3101,8 @@ CBlockIndex* BlockManager::AddToBlockIndex(const CBlockHeader& block)

// Use memcpy to copy the entire array at once.
if (pindexNew->pprev) {
// Copy parent's lastAlgoBlocks
std::memcpy(
pindexNew->lastAlgoBlocks,
pindexNew->pprev->lastAlgoBlocks,
sizeof(pindexNew->lastAlgoBlocks)
);

// Overwrite the slot for the new block's own algo
// (the constructor sets just one entry, but we also
// want the rest of them to reference parent's data)
memcpy(pindexNew->lastAlgoBlocks, pindexNew->pprev->lastAlgoBlocks, sizeof(pindexNew->lastAlgoBlocks));
pindexNew->lastAlgoBlocks[pindexNew->GetAlgo()] = pindexNew;
} else {
// For the genesis block, or if no parent:
// Already set to nullptr in the constructor for all algos,
// plus we set the entry for pindexNew->GetAlgo():
// (the existing constructor call does something like:
// for (...) lastAlgoBlocks[i] = nullptr;
// lastAlgoBlocks[GetAlgo()] = this;)
}

pindexNew->nTimeMax = (pindexNew->pprev ? std::max(pindexNew->pprev->nTimeMax, pindexNew->nTime) : pindexNew->nTime);
Expand Down

0 comments on commit 6e2cf3d

Please sign in to comment.