Handle negative timeout for waitTipChanged()

This commit is contained in:
Sjors Provoost
2025-02-19 15:54:35 +01:00
parent c20a5ce106
commit f9cf8bd0ab
2 changed files with 4 additions and 1 deletions

View File

@@ -1072,6 +1072,8 @@ public:
BlockRef waitTipChanged(uint256 current_tip, MillisecondsDouble timeout) override
{
Assume(timeout >= 0ms); // No internal callers should use a negative timeout
if (timeout < 0ms) timeout = 0ms;
if (timeout > std::chrono::years{100}) timeout = std::chrono::years{100}; // Upper bound to avoid UB in std::chrono
{
WAIT_LOCK(notifications().m_tip_block_mutex, lock);