Skip to content

Commit

Permalink
src: use unique_ptr for CachedData in ContextifyScript::New
Browse files Browse the repository at this point in the history
This closes a memory leak.

PR-URL: #33113
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
  • Loading branch information
addaleax authored and targos committed May 13, 2020
1 parent 843a54f commit ffca498
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_contextify.cc
Expand Up @@ -761,8 +761,8 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& 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<ScriptCompiler::CachedData> cached_data {
ScriptCompiler::CreateCodeCache(v8_script.ToLocalChecked()) };
bool cached_data_produced = cached_data != nullptr;
if (cached_data_produced) {
MaybeLocal<Object> buf = Buffer::Copy(
Expand Down

0 comments on commit ffca498

Please sign in to comment.