Skip to content

Commit a01154e

Browse files
addaleaxdanielleadams
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 fcbdb06 commit a01154e

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
@@ -519,7 +519,9 @@ class NativeKeyObject : public BaseObject {
519519
v8::Local<v8::Object> wrap,
520520
const std::shared_ptr<KeyObjectData>& handle_data)
521521
: BaseObject(env, wrap),
522-
handle_data_(handle_data) {}
522+
handle_data_(handle_data) {
523+
MakeWeak();
524+
}
523525

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

0 commit comments

Comments
 (0)