Skip to content

Commit

Permalink
Bluelink: fix error if length of stamps is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Nov 12, 2022
1 parent 451be5e commit e1b19a3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vehicle/bluelink/stamps.go
@@ -1,6 +1,7 @@
package bluelink

import (
"errors"
"fmt"
"sync"
"time"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit e1b19a3

Please sign in to comment.