Skip to content

Commit

Permalink
napi: initialize and check status properly
Browse files Browse the repository at this point in the history
Initialize status to napi_generic_failure and only check it after
having made an actual N-API call.

This fixes up 8fbace1.

Backport-PR-URL: #19447
PR-URL: #12283
Ref: #12279
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
Gabriel Schulhof authored and MylesBorins committed Apr 16, 2018
1 parent 2a72622 commit a6af97f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/node_api.cc
Expand Up @@ -2164,7 +2164,7 @@ napi_status napi_instanceof(napi_env env,

if (env->has_instance_available) {
napi_value value, js_result, has_instance = nullptr;
napi_status status;
napi_status status = napi_generic_failure;
napi_valuetype value_type;

// Get "Symbol" from the global object
Expand All @@ -2187,14 +2187,12 @@ napi_status napi_instanceof(napi_env env,
if (value_type == napi_symbol) {
env->has_instance.Reset(env->isolate,
v8impl::V8LocalValueFromJsValue(value));
if (status != napi_ok) return status;
has_instance = value;
}
}
} else {
has_instance = v8impl::JsValueFromV8LocalValue(
v8::Local<v8::Value>::New(env->isolate, env->has_instance));
if (status != napi_ok) return status;
}

if (has_instance) {
Expand Down

0 comments on commit a6af97f

Please sign in to comment.