From 09b403bea30841c831ab9a8138eb32f3bab1c12e Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sat, 14 Sep 2019 14:36:05 +0200 Subject: [PATCH] Fix: Don't divide by zero Signed-off-by: Knut Ahlers --- token.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/token.go b/token.go index aab5910..5431886 100644 --- a/token.go +++ b/token.go @@ -79,11 +79,16 @@ func (t tokenList) MinPeriod() int { var m int = math.MaxInt32 for _, tok := range t { - if tok.Period < m { + if tok.Period != 0 && tok.Period < m { m = tok.Period } } + if m == math.MaxInt32 { + // Fallback: Everything uses the default value + m = 30 + } + return m }