Skip to content

Commit afd5966

Browse files
Gabriel Schulhofrefack
Gabriel Schulhof
authored andcommitted
napi: initialize and check status properly
Initialize status to napi_generic_failure and only check it after having made an actual N-API call. This fixes up 8fbace1. PR-URL: #12283 Ref: #12279 Reviewed-By: Refael Ackermann <[email protected]>
1 parent 14749f9 commit afd5966

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/node_api.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,7 @@ napi_status napi_instanceof(napi_env env,
21622162

21632163
if (env->has_instance_available) {
21642164
napi_value value, js_result, has_instance = nullptr;
2165-
napi_status status;
2165+
napi_status status = napi_generic_failure;
21662166
napi_valuetype value_type;
21672167

21682168
// Get "Symbol" from the global object
@@ -2185,14 +2185,12 @@ napi_status napi_instanceof(napi_env env,
21852185
if (value_type == napi_symbol) {
21862186
env->has_instance.Reset(env->isolate,
21872187
v8impl::V8LocalValueFromJsValue(value));
2188-
if (status != napi_ok) return status;
21892188
has_instance = value;
21902189
}
21912190
}
21922191
} else {
21932192
has_instance = v8impl::JsValueFromV8LocalValue(
21942193
v8::Local<v8::Value>::New(env->isolate, env->has_instance));
2195-
if (status != napi_ok) return status;
21962194
}
21972195

21982196
if (has_instance) {

0 commit comments

Comments
 (0)