Skip to content

Commit e0d81d1

Browse files
authored
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.
1 parent 5e6f737 commit e0d81d1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

eth/dropper.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ func randomDuration(min, max time.Duration) time.Duration {
145145
if min > max {
146146
panic("min duration must be less than or equal to max duration")
147147
}
148+
if min == max {
149+
return min
150+
}
148151
return time.Duration(mrand.Int63n(int64(max-min)) + int64(min))
149152
}
150153

0 commit comments

Comments
 (0)