Skip to content

Commit a6af97f

Browse files
Gabriel SchulhofMylesBorins
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. Backport-PR-URL: #19447 PR-URL: #12283 Ref: #12279 Reviewed-By: Refael Ackermann <[email protected]>
1 parent 2a72622 commit a6af97f

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
@@ -2164,7 +2164,7 @@ napi_status napi_instanceof(napi_env env,
21642164

21652165
if (env->has_instance_available) {
21662166
napi_value value, js_result, has_instance = nullptr;
2167-
napi_status status;
2167+
napi_status status = napi_generic_failure;
21682168
napi_valuetype value_type;
21692169

21702170
// Get "Symbol" from the global object
@@ -2187,14 +2187,12 @@ napi_status napi_instanceof(napi_env env,
21872187
if (value_type == napi_symbol) {
21882188
env->has_instance.Reset(env->isolate,
21892189
v8impl::V8LocalValueFromJsValue(value));
2190-
if (status != napi_ok) return status;
21912190
has_instance = value;
21922191
}
21932192
}
21942193
} else {
21952194
has_instance = v8impl::JsValueFromV8LocalValue(
21962195
v8::Local<v8::Value>::New(env->isolate, env->has_instance));
2197-
if (status != napi_ok) return status;
21982196
}
21992197

22002198
if (has_instance) {

0 commit comments

Comments
 (0)