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 4, 2020
1 parent 3866dc1 commit de643bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,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 de643bc

Please sign in to comment.