Skip to content
Snippets Groups Projects
Verified Commit 5eb3aa0a authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Add null check for account keys

parent 4a598632
No related branches found
No related tags found
No related merge requests found
Pipeline #1862 failed
......@@ -62,7 +62,8 @@ public:
{}
olm_exception(std::string func, OlmAccount *acc)
: olm_exception(std::move(func), std::string(olm_account_last_error(acc)))
: olm_exception(std::move(func),
std::string(acc ? olm_account_last_error(acc) : "account == nullptr"))
{}
olm_exception(std::string func, OlmUtility *util)
......
......@@ -69,6 +69,9 @@ OlmClient::restore_account(const std::string &saved_data, const std::string &key
mtx::crypto::IdentityKeys
OlmClient::identity_keys() const
{
if (!account_)
throw olm_exception("identity_keys", account_.get());
auto tmp_buf = create_buffer(olm_account_identity_keys_length(account_.get()));
auto ret = olm_account_identity_keys(account_.get(), (void *)tmp_buf.data(), tmp_buf.size());
......
......@@ -68,6 +68,9 @@ TEST(Encryption, UploadIdentityKeys)
{
auto alice = make_test_client();
auto olm_account = std::make_shared<mtx::crypto::OlmClient>();
EXPECT_THROW(olm_account->identity_keys(), olm_exception);
olm_account->create_new_account();
alice->login(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment