Skip to content

Commit eeb112f

Browse files
furszyFuzzbawls
authored andcommitted
GetMasternodeInputAge: Missing cs_main lock
Github-Pull: #1791 Rebased-From: 224c8fd
1 parent 52ec12d commit eeb112f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/masternode.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,20 @@ class CMasternode : public CSignedMessage
251251

252252
int GetMasternodeInputAge()
253253
{
254-
if (chainActive.Tip() == NULL) return 0;
254+
int tipHeight;
255+
{
256+
LOCK(cs_main);
257+
CBlockIndex *pindex = chainActive.Tip();
258+
if (!pindex) return 0;
259+
tipHeight = pindex->nHeight;
260+
}
255261

256262
if (cacheInputAge == 0) {
257263
cacheInputAge = GetInputAge(vin);
258-
cacheInputAgeBlock = chainActive.Tip()->nHeight;
264+
cacheInputAgeBlock = tipHeight;
259265
}
260266

261-
return cacheInputAge + (chainActive.Tip()->nHeight - cacheInputAgeBlock);
267+
return cacheInputAge + (tipHeight - cacheInputAgeBlock);
262268
}
263269

264270
std::string Status()

0 commit comments

Comments
 (0)