From 868abfeae69fe578a07529f2c62c21797ef69ecf Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 20 Mar 2024 20:26:28 +0100 Subject: [PATCH] Fix possible crash for unexpected response --- settings/changed.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/settings/changed.go b/settings/changed.go index 93221aa..6e7eaf4 100644 --- a/settings/changed.go +++ b/settings/changed.go @@ -36,9 +36,20 @@ func OnSignalSettingChanged(callback func(changed Changed)) error { continue } - changed := Changed{Namespace: sig.Body[0].(string)} + namespace, ok := sig.Body[0].(string) + if !ok { + continue // We sometimes get responses from other portals. + } + + changed := Changed{Namespace: namespace} + if len(sig.Body) > 1 { - changed.Key = sig.Body[1].(string) + key, ok := sig.Body[1].(string) + if !ok { + continue // Avoid crashing if the response is unexpected. + } + + changed.Key = key } if len(sig.Body) > 2 {