Skip to content

Commit

Permalink
fix: assertion on nil
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelemusiani committed Apr 3, 2024
1 parent 0f02ce2 commit ae494ec
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/macpassd/registration/safemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ func (m *safeMap) remove(mac string) {
// in the m map. If the ip is in the OldIPs files nothing is done
func (m *safeMap) addIp(mac string, ip net.IP) {
aval, present := m.v.Load(mac)
val, ok := aval.(Registration)
if present {
val, ok := aval.(Registration)

if !ok {
slog.With("ok", ok, "aval", aval).
Error("Type assertion failed. Could not converto aval to type Registration")
log.Fatal("Could not continue")
}
if !ok {
slog.With("ok", ok, "aval", aval).
Error("Type assertion failed. Could not converto aval to type Registration")
log.Fatal("Could not continue")
}

if present {
if !isIpPrenset(val.Ips, ip) && !isIpPrenset(val.OldIps, ip) {
val.Ips = append(val.Ips, ip) //Need to check for duplicates
slog.With("registration", val.String()).
Expand Down

0 comments on commit ae494ec

Please sign in to comment.