From e1b19a3d87170e0506f3a2fd897095b63fb0669c Mon Sep 17 00:00:00 2001 From: andig Date: Sat, 12 Nov 2022 17:54:13 +0100 Subject: [PATCH] Bluelink: fix error if length of stamps is 0 --- vehicle/bluelink/stamps.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vehicle/bluelink/stamps.go b/vehicle/bluelink/stamps.go index 5aa0c692dc..b94757b677 100644 --- a/vehicle/bluelink/stamps.go +++ b/vehicle/bluelink/stamps.go @@ -1,6 +1,7 @@ package bluelink import ( + "errors" "fmt" "sync" "time" @@ -55,6 +56,10 @@ func (c *stampCollection) Get() (string, error) { position = int(time.Since(c.Generated).Milliseconds()) / c.Frequency } + if len(c.Stamps) == 0 { + return "", errors.New("no stamps available") + } + if position >= len(c.Stamps) { position = len(c.Stamps) - 1 }