From de643bc325cd61b35a8864ccdc985fbb6b201471 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 28 Apr 2020 04:06:09 +0200 Subject: [PATCH] src: use unique_ptr for CachedData in ContextifyScript::New This closes a memory leak. PR-URL: https://github.com/nodejs/node/pull/33113 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Gus Caplan --- src/node_contextify.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 7926965302161c..34dbdf08420329 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -764,8 +764,8 @@ void ContextifyScript::New(const FunctionCallbackInfo& args) { env->cached_data_rejected_string(), Boolean::New(isolate, source.GetCachedData()->rejected)).Check(); } else if (produce_cached_data) { - const ScriptCompiler::CachedData* cached_data = - ScriptCompiler::CreateCodeCache(v8_script.ToLocalChecked()); + std::unique_ptr cached_data { + ScriptCompiler::CreateCodeCache(v8_script.ToLocalChecked()) }; bool cached_data_produced = cached_data != nullptr; if (cached_data_produced) { MaybeLocal buf = Buffer::Copy(