Skip to content

Commit 9024436

Browse files
addaleaxMylesBorins
authored andcommitted
crypto: fix KeyObject garbage collection
These objects don’t hold any resources on the event loop, so they should be weak objects that can be garbage collected when nothing refers to them anymore. PR-URL: #35481 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 1cd1d01 commit 9024436

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/node_crypto.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,9 @@ class NativeKeyObject : public BaseObject {
518518
v8::Local<v8::Object> wrap,
519519
const std::shared_ptr<KeyObjectData>& handle_data)
520520
: BaseObject(env, wrap),
521-
handle_data_(handle_data) {}
521+
handle_data_(handle_data) {
522+
MakeWeak();
523+
}
522524

523525
std::shared_ptr<KeyObjectData> handle_data_;
524526
};

0 commit comments

Comments
 (0)