Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32562788
D14464.1767345427.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D14464.1767345427.diff
View Options
diff --git a/keyserver/src/utils/olm-objects.js b/keyserver/src/utils/olm-objects.js
--- a/keyserver/src/utils/olm-objects.js
+++ b/keyserver/src/utils/olm-objects.js
@@ -27,20 +27,21 @@
const account = new olm.Account();
account.unpickle(picklingKey, pickledAccount);
- let result;
try {
- result = await callback(account, picklingKey);
+ const result = await callback(account, picklingKey);
+ const updatedAccount = account.pickle(picklingKey);
+ return {
+ result,
+ pickledOlmAccount: {
+ ...pickledOlmAccount,
+ pickledAccount: updatedAccount,
+ },
+ };
} catch (e) {
throw new ServerError(getMessageForException(e) ?? 'unknown_error');
+ } finally {
+ account.free();
}
- const updatedAccount = account.pickle(picklingKey);
-
- account.free();
-
- return {
- result,
- pickledOlmAccount: { ...pickledOlmAccount, pickledAccount: updatedAccount },
- };
}
async function createPickledOlmAccount(): Promise<PickledOlmAccount> {
@@ -75,23 +76,21 @@
const session = new olm.Session();
session.unpickle(picklingKey, pickledSession);
- let result;
try {
- result = await callback(session);
+ const result = await callback(session);
+ const updatedSession = session.pickle(picklingKey);
+ return {
+ result,
+ pickledOlmSession: {
+ ...pickledOlmSession,
+ pickledSession: updatedSession,
+ },
+ };
} catch (e) {
throw new ServerError(getMessageForException(e) ?? 'unknown_error');
+ } finally {
+ session.free();
}
- const updatedSession = session.pickle(picklingKey);
-
- session.free();
-
- return {
- result,
- pickledOlmSession: {
- ...pickledOlmSession,
- pickledSession: updatedSession,
- },
- };
}
async function createPickledOlmSession(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 2, 9:17 AM (5 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5878923
Default Alt Text
D14464.1767345427.diff (1 KB)
Attached To
Mode
D14464: [keyserver] call `free()` on Olm objects in finally block
Attached
Detach File
Event Timeline
Log In to Comment