From 0fd915ee6bef63bb360ccc5c039a3c11676c38e3 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Thu, 8 Feb 2024 11:37:19 -0500 Subject: [PATCH] validation: Check GuessVerificationProgress is not called with disconnected block Use Assume macro as suggested https://github.com/bitcoin/bitcoin/pull/29370#discussion_r1479427801 --- src/validation.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/validation.cpp b/src/validation.cpp index 94d2680db7..02f415101e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5286,6 +5286,12 @@ double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex *pin if (pindex == nullptr) return 0.0; + if (!Assume(pindex->nChainTx > 0)) { + LogWarning("Internal bug detected: block %d has unset nChainTx (%s %s). Please report this issue here: %s\n", + pindex->nHeight, PACKAGE_NAME, FormatFullVersion(), PACKAGE_BUGREPORT); + return 0.0; + } + int64_t nNow = time(nullptr); double fTxTotal;