summaryrefslogtreecommitdiff
path: root/src/node_contextify.cc
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-07-09 18:21:03 -0400
committercjihrig <cjihrig@gmail.com>2019-07-12 09:07:23 -0400
commit641d57fc0abb90033b976356dc3f5c8220d3bf71 (patch)
tree308ca5d7f18ab32cf520793bedb987ba0d8694db /src/node_contextify.cc
parentfe1b96d460b8d8c7895e91b2ab57ee1fbc0f0052 (diff)
downloadandroid-node-v8-641d57fc0abb90033b976356dc3f5c8220d3bf71.tar.gz
android-node-v8-641d57fc0abb90033b976356dc3f5c8220d3bf71.tar.bz2
android-node-v8-641d57fc0abb90033b976356dc3f5c8220d3bf71.zip
src: manage MakeContext() pointer with unique_ptr
PR-URL: https://github.com/nodejs/node/pull/28616 Refs: https://github.com/nodejs/node/pull/28452 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_contextify.cc')
-rw-r--r--src/node_contextify.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index a13eed9d0f..c6b9dc18de 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -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()));
}