Skip to content

Commit

Permalink
crypto: fix KeyObject garbage collection
Browse files Browse the repository at this point in the history
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: nodejs#35481
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
addaleax authored and joesepi committed Oct 22, 2020
1 parent 86512fe commit 9641ca6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,9 @@ class NativeKeyObject : public BaseObject {
v8::Local<v8::Object> wrap,
const std::shared_ptr<KeyObjectData>& handle_data)
: BaseObject(env, wrap),
handle_data_(handle_data) {}
handle_data_(handle_data) {
MakeWeak();
}

std::shared_ptr<KeyObjectData> handle_data_;
};
Expand Down

0 comments on commit 9641ca6

Please sign in to comment.