Fix panic when no timers are left after dispatch

This commit is contained in:
Kovid Goyal 2022-12-31 13:30:46 +05:30
parent d76e0850ae
commit 22d69d24d0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -325,9 +325,12 @@ func (self *Loop) run() (err error) {
if err != nil { if err != nil {
return err return err
} }
timeout := self.timers[0].deadline.Sub(now) var timeout time.Duration
if timeout < 0 { if len(self.timers) > 0 {
timeout = 0 timeout = self.timers[0].deadline.Sub(now)
if timeout < 0 {
timeout = 0
}
} }
timeout_chan = time.After(timeout) timeout_chan = time.After(timeout)
} }