From 544019f67db0172e07d3c4f0f8a51f14fa424a34 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 28 Oct 2021 11:52:32 +0200 Subject: [PATCH] ensure olm Account in dehydrated device is freed on error --- src/matrix/SessionContainer.js | 2 ++ src/matrix/e2ee/Dehydration.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/matrix/SessionContainer.js b/src/matrix/SessionContainer.js index 9794e93a..6b194c9b 100644 --- a/src/matrix/SessionContainer.js +++ b/src/matrix/SessionContainer.js @@ -189,6 +189,8 @@ export class SessionContainer { log.set("status", this._status.get()); } catch (err) { log.catch(err); + // free olm Account that might be contained + dehydratedDevice?.dispose(); this._error = err; this._status.set(LoadStatus.Error); } diff --git a/src/matrix/e2ee/Dehydration.js b/src/matrix/e2ee/Dehydration.js index 4fa75d81..22d6082b 100644 --- a/src/matrix/e2ee/Dehydration.js +++ b/src/matrix/e2ee/Dehydration.js @@ -90,11 +90,16 @@ class DehydratedDevice { // make it clear that ownership is transfered upon calling this adoptUnpickledOlmAccount() { const account = this._account; - this._account = null; + this._account = undefined; return account; } get deviceId() { return this._dehydratedDevice.device_id; } + + dispose() { + this._account?.free(); + this._account = undefined; + } }