From e8d511a3712830655a256060d706cec87ef42d46 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Tue, 27 Jul 2021 10:49:50 +0200 Subject: [PATCH] fix: Missing null checks in syncUpdate handling --- lib/encryption/ssss.dart | 1 + lib/encryption/utils/bootstrap.dart | 1 + lib/src/client.dart | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/encryption/ssss.dart b/lib/encryption/ssss.dart index 95f64d82..dd9c7a05 100644 --- a/lib/encryption/ssss.dart +++ b/lib/encryption/ssss.dart @@ -233,6 +233,7 @@ class SSSS { final accountDataType = EventTypes.secretStorageKey(keyId); // noooow we set the account data final waitForAccountData = client.onSync.stream.firstWhere((syncUpdate) => + syncUpdate.accountData != null && syncUpdate.accountData .any((accountData) => accountData.type == accountDataType)); await client.setAccountData( diff --git a/lib/encryption/utils/bootstrap.dart b/lib/encryption/utils/bootstrap.dart index aab657a8..843489d2 100644 --- a/lib/encryption/utils/bootstrap.dart +++ b/lib/encryption/utils/bootstrap.dart @@ -290,6 +290,7 @@ class Bootstrap { // alright, we re-encrypted all the secrets. We delete the dead weight only *after* we set our key to the default key } final updatedAccountData = client.onSync.stream.firstWhere((syncUpdate) => + syncUpdate.accountData != null && syncUpdate.accountData.any((accountData) => accountData.type == EventTypes.SecretStorageDefaultKey)); await encryption.ssss.setDefaultKeyId(newSsssKey.keyId); diff --git a/lib/src/client.dart b/lib/src/client.dart index 20858763..ac039bed 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -647,7 +647,7 @@ class Client extends MatrixApi { filter: '{"room":{"include_leave":true,"timeline":{"limit":10}}}', timeout: 0, ); - if (syncResp.rooms.leave is Map) { + if (syncResp.rooms?.leave != null) { for (final entry in syncResp.rooms.leave.entries) { final id = entry.key; final room = entry.value;