From f0dcc60a17fb63e17916bb8653d25539d87ef283 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Wed, 28 Feb 2024 11:36:13 +0000 Subject: [PATCH] fix: check nil pointer in saveProfileShowcasePreferencesProto (#4821) --- protocol/messenger_backup_handler.go | 4 +++- protocol/messenger_profile_showcase.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/protocol/messenger_backup_handler.go b/protocol/messenger_backup_handler.go index 5f83877dc..d3eb1d680 100644 --- a/protocol/messenger_backup_handler.go +++ b/protocol/messenger_backup_handler.go @@ -181,7 +181,9 @@ func (m *Messenger) handleBackedUpProfile(message *protobuf.BackedUpProfile, bac if err != nil { return err } - response.SetProfileShowcasePreferences(profileShowcasePreferences) + if profileShowcasePreferences != nil { + response.SetProfileShowcasePreferences(profileShowcasePreferences) + } var ensUsernameDetails []*ensservice.UsernameDetail for _, d := range message.EnsUsernameDetails { diff --git a/protocol/messenger_profile_showcase.go b/protocol/messenger_profile_showcase.go index 2b53c7c26..8a1d369c8 100644 --- a/protocol/messenger_profile_showcase.go +++ b/protocol/messenger_profile_showcase.go @@ -669,6 +669,9 @@ func (m *Messenger) DeleteProfileShowcaseCommunity(community *communities.Commun } func (m *Messenger) saveProfileShowcasePreferencesProto(p *protobuf.SyncProfileShowcasePreferences, shouldSync bool) (*identity.ProfileShowcasePreferences, error) { + if p == nil { + return nil, nil + } preferences := FromProfileShowcasePreferencesProto(p) return preferences, m.setProfileShowcasePreferences(preferences, shouldSync) }