From 5a79a72ff51731541a540b062a3265e2eb18399d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 19 Jan 2023 16:55:11 +0100 Subject: [PATCH] Heartbeat#sendEvent(m): nil-check m before dereferencing it as it can be nil. --- pkg/icingaredis/heartbeat.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/icingaredis/heartbeat.go b/pkg/icingaredis/heartbeat.go index 99670d906..9a8ebadcb 100644 --- a/pkg/icingaredis/heartbeat.go +++ b/pkg/icingaredis/heartbeat.go @@ -179,9 +179,12 @@ func (h *Heartbeat) sendEvent(m *HeartbeatMessage) { select { case old := <-h.events: if old != nil { - h.logger.Debugw("Previous heartbeat not read from channel", - zap.Time("previous", old.received), - zap.Time("current", m.received)) + kv := []any{zap.Time("previous", old.received)} + if m != nil { + kv = append(kv, zap.Time("current", m.received)) + } + + h.logger.Debugw("Previous heartbeat not read from channel", kv...) } else { h.logger.Debug("Previous heartbeat loss event not read from channel") }