From 90244362cca9e615af03132b383a889881f6d529 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 3 Oct 2020 19:45:42 +0200 Subject: [PATCH] crypto: fix KeyObject garbage collection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Colin Ihrig --- src/node_crypto.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node_crypto.h b/src/node_crypto.h index 52b3044bd08da0..573d59ddf41771 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -518,7 +518,9 @@ class NativeKeyObject : public BaseObject { v8::Local wrap, const std::shared_ptr& handle_data) : BaseObject(env, wrap), - handle_data_(handle_data) {} + handle_data_(handle_data) { + MakeWeak(); + } std::shared_ptr handle_data_; };