mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
eth: fix panic in randomDuration when min equals max (#33193)
Fixes a potential panic in `randomDuration` when `min == max` by handling the edge case explicitly.
This commit is contained in:
parent
5e6f7374de
commit
e0d81d1e99
1 changed files with 3 additions and 0 deletions
|
|
@ -145,6 +145,9 @@ func randomDuration(min, max time.Duration) time.Duration {
|
||||||
if min > max {
|
if min > max {
|
||||||
panic("min duration must be less than or equal to max duration")
|
panic("min duration must be less than or equal to max duration")
|
||||||
}
|
}
|
||||||
|
if min == max {
|
||||||
|
return min
|
||||||
|
}
|
||||||
return time.Duration(mrand.Int63n(int64(max-min)) + int64(min))
|
return time.Duration(mrand.Int63n(int64(max-min)) + int64(min))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue