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: https://github.com/nodejs/node/pull/35481
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Anna Henningsen authored and Myles Borins committed 2020-11-16 11:58:05 -05:00
1 parent 1cd1d0159d
commit 90244362cc
1 file changed
+3 -1
+3 -1
View File
@@ -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_;
};