Merge pull request #559 from Icinga/segv

Heartbeat#sendEvent(m): nil-check m before dereferencing it
This commit is contained in:
Julian Brost 2023-06-05 12:54:29 +02:00 committed by GitHub
commit 78fa223cab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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")
}