Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: use unique_ptr for CachedData in ContextifyScript::New
This closes a memory leak.
  • Loading branch information
addaleax committed Apr 28, 2020
commit cda14874308b78b69b3cc353b9abe7589bc5e202
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