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 danielleadams committed Oct 6, 2020
1 parent fcbdb06 commit a01154e
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 a01154e

Please sign in to comment.