Skip to content

Commit 74b906e

Browse files
committed
TimedAttempt: fix reload overflow
1 parent b9c21cd commit 74b906e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utility/time/TimedAttempt.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ unsigned long TimedAttempt::retry() {
5252
}
5353

5454
unsigned long TimedAttempt::reload() {
55-
unsigned long retryDelay = (1 << _retryCount) * _minDelay;
56-
_retryDelay = min(retryDelay, _maxDelay);
55+
unsigned long shift = _retryCount > 31 ? 31 : _retryCount;
56+
unsigned long delay = (1UL << shift) * _minDelay;
57+
_retryDelay = min(delay, _maxDelay);
5758
_retryTick = millis();
5859
return _retryDelay;
5960
}

0 commit comments

Comments
 (0)