2441 | @@ -2442,17 +2442,23 @@ bool CChainState::ConnectTip(CValidationState& state, const CChainParams& chainp
2442 | return error("%s: ConnectBlock %s failed, %s", __func__, pindexNew->GetBlockHash().ToString(), FormatStateMessage(state));
2443 | }
2444 | nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2;
2445 | - LogPrint(BCLog::BENCH, " - Connect total: %.2fms [%.2fs (%.2fms/blk)]\n", (nTime3 - nTime2) * MILLI, nTimeConnectTotal * MICRO, nTimeConnectTotal * MILLI / nBlocksTotal);
2446 | + if (nBlocksTotal != 0) {
I don't think nBlocksTotal can be zero? So at this point we could just assert(nBlocksTotal > 0) and ignore these remaining changes.
nBlocksTotal can be zero: this UB is triggered when running the functional tests.
As said in the PR description:
UBSAN in Travis running the test suite would have catched all three of these.
:-)