prevent leaking resources in olm worker
This commit is contained in:
parent
5f6ad91ff2
commit
f13f1cd593
1 changed files with 13 additions and 7 deletions
|
@ -116,14 +116,13 @@ class MessageHandler {
|
||||||
|
|
||||||
_megolmDecrypt(sessionKey, ciphertext) {
|
_megolmDecrypt(sessionKey, ciphertext) {
|
||||||
return this._toMessage(() => {
|
return this._toMessage(() => {
|
||||||
let session;
|
const session = new this._olm.InboundGroupSession();
|
||||||
try {
|
try {
|
||||||
session = new this._olm.InboundGroupSession();
|
|
||||||
session.import_session(sessionKey);
|
session.import_session(sessionKey);
|
||||||
// returns object with plaintext and message_index
|
// returns object with plaintext and message_index
|
||||||
return session.decrypt(ciphertext);
|
return session.decrypt(ciphertext);
|
||||||
} finally {
|
} finally {
|
||||||
session?.free();
|
session.free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -132,10 +131,17 @@ class MessageHandler {
|
||||||
return this._toMessage(() => {
|
return this._toMessage(() => {
|
||||||
this._feedRandomValues(randomValues);
|
this._feedRandomValues(randomValues);
|
||||||
const account = new this._olm.Account();
|
const account = new this._olm.Account();
|
||||||
|
try {
|
||||||
account.create();
|
account.create();
|
||||||
account.generate_one_time_keys(otkAmount);
|
account.generate_one_time_keys(otkAmount);
|
||||||
this._checkRandomValuesUsed();
|
this._checkRandomValuesUsed();
|
||||||
return account.pickle("");
|
return account.pickle("");
|
||||||
|
} finally {
|
||||||
|
account.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
_olmCreateOutbound(accountPickle, theirIdentityKey, theirOneTimeKey) {
|
_olmCreateOutbound(accountPickle, theirIdentityKey, theirOneTimeKey) {
|
||||||
return this._toMessage(() => {
|
return this._toMessage(() => {
|
||||||
const account = new this._olm.Account();
|
const account = new this._olm.Account();
|
||||||
|
|
Reference in a new issue