From ea95ce2d4b33d40d812694c4633098dee92c8438 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Thu, 2 Dec 2021 13:55:30 +0200 Subject: [PATCH] Add nil check for DirectMessageProtocol object --- protocol/encryption/protocol.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/protocol/encryption/protocol.go b/protocol/encryption/protocol.go index aa2a7ba27..772ad810c 100644 --- a/protocol/encryption/protocol.go +++ b/protocol/encryption/protocol.go @@ -477,12 +477,14 @@ func (p *Protocol) HandleMessage( if dmProtocol == nil { dmProtocol = encryptedMessage[noInstallationID] } - hrHeader := dmProtocol.HRHeader - if hrHeader != nil && hrHeader.SeqNo == 0 { - // Payload contains hash ratchet key - err = p.encryptor.persistence.SaveHashRatchetKey(hrHeader.GroupId, hrHeader.KeyId, message) - if err != nil { - return nil, err + if dmProtocol != nil { + hrHeader := dmProtocol.HRHeader + if hrHeader != nil && hrHeader.SeqNo == 0 { + // Payload contains hash ratchet key + err = p.encryptor.persistence.SaveHashRatchetKey(hrHeader.GroupId, hrHeader.KeyId, message) + if err != nil { + return nil, err + } } }