Skip to content

Commit

Permalink
Fix possible crash for unexpected response
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Mar 20, 2024
1 parent a0b0dc5 commit 868abfe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions settings/changed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 868abfe

Please sign in to comment.