Skip to content
Merged
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: manage MakeContext() pointer with unique_ptr
PR-URL: #28616
Refs: #28452
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
cjihrig committed Jul 12, 2019
commit 641d57fc0abb90033b976356dc3f5c8220d3bf71
9 changes: 3 additions & 6 deletions src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,21 @@ void ContextifyContext::MakeContext(const FunctionCallbackInfo<Value>& args) {
options.allow_code_gen_wasm = args[4].As<Boolean>();

TryCatchScope try_catch(env);
ContextifyContext* context = new ContextifyContext(env, sandbox, options);
auto context_ptr = std::make_unique<ContextifyContext>(env, sandbox, options);

if (try_catch.HasCaught()) {
if (!try_catch.HasTerminated())
try_catch.ReThrow();
delete context;
return;
}

if (context->context().IsEmpty()) {
delete context;
if (context_ptr->context().IsEmpty())
return;
}

sandbox->SetPrivate(
env->context(),
env->contextify_context_private_symbol(),
External::New(env->isolate(), context));
External::New(env->isolate(), context_ptr.release()));
}


Expand Down