Skip to content

Commit aef34f7

Browse files
fix: prevent null pointer dereference in CalcCbTxMerkleRootMNList
Add null check before dereferencing cached_sml in comparison to prevent potential crash when cached_sml is null. The comparison now safely checks if cached_sml exists before attempting to dereference it. This fixes a critical bug where *cached_sml could be dereferenced when cached_sml is null, leading to undefined behavior.
1 parent a922815 commit aef34f7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/evo/cbtx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bool CalcCbTxMerkleRootMNList(uint256& merkleRootRet, const CDeterministicMNList
104104

105105
std::shared_ptr<const CSimplifiedMNList> sml{mn_list.to_sml()};
106106
LOCK(cached_mutex);
107-
if (sml == cached_sml || *sml == *cached_sml) {
107+
if (sml == cached_sml || (cached_sml && *sml == *cached_sml)) {
108108
merkleRootRet = merkleRootCached;
109109
if (mutatedCached) {
110110
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "mutated-cached-calc-cb-mnmerkleroot");

0 commit comments

Comments
 (0)