Skip to content

Commit e9f3aa5

Browse files
vasildjonatack
authored andcommitted
Require CBlockIndex::RaiseValidity() to hold cs_main
1 parent 8ef457c commit e9f3aa5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/chain.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ class CBlockIndex
328328

329329
//! Raise the validity level of this block index entry.
330330
//! Returns true if the validity was changed.
331-
bool RaiseValidity(enum BlockStatus nUpTo)
331+
bool RaiseValidity(enum BlockStatus nUpTo) EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
332332
{
333+
AssertLockHeld(::cs_main);
333334
assert(!(nUpTo & ~BLOCK_VALID_MASK)); // Only validity flags allowed.
334335
if (nStatus & BLOCK_FAILED_MASK) return false;
335336

src/test/fuzz/chain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ FUZZ_TARGET(chain)
5858
if (block_status & ~BLOCK_VALID_MASK) {
5959
continue;
6060
}
61-
(void)disk_block_index->RaiseValidity(block_status);
61+
WITH_LOCK(::cs_main, (void)disk_block_index->RaiseValidity(block_status));
6262
}
6363

6464
CBlockIndex block_index{block_header};

0 commit comments

Comments
 (0)