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: #35481
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed Nov 16, 2020
1 parent 1cd1d01 commit 9024436
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/node_crypto.h
Expand Up @@ -518,7 +518,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 9024436

Please sign in to comment.