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 8fbace163afbd61b5efc57cf94414be904bf0188. PR-URL: https://github.com/nodejs/node/pull/12283 Ref: https://github.com/nodejs/node/pull/12279 Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
parent
14749f9eaf
commit
afd5966fa9
@ -2162,7 +2162,7 @@ napi_status napi_instanceof(napi_env env,
|
|||||||
|
|
||||||
if (env->has_instance_available) {
|
if (env->has_instance_available) {
|
||||||
napi_value value, js_result, has_instance = nullptr;
|
napi_value value, js_result, has_instance = nullptr;
|
||||||
napi_status status;
|
napi_status status = napi_generic_failure;
|
||||||
napi_valuetype value_type;
|
napi_valuetype value_type;
|
||||||
|
|
||||||
// Get "Symbol" from the global object
|
// Get "Symbol" from the global object
|
||||||
@ -2185,14 +2185,12 @@ napi_status napi_instanceof(napi_env env,
|
|||||||
if (value_type == napi_symbol) {
|
if (value_type == napi_symbol) {
|
||||||
env->has_instance.Reset(env->isolate,
|
env->has_instance.Reset(env->isolate,
|
||||||
v8impl::V8LocalValueFromJsValue(value));
|
v8impl::V8LocalValueFromJsValue(value));
|
||||||
if (status != napi_ok) return status;
|
|
||||||
has_instance = value;
|
has_instance = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
has_instance = v8impl::JsValueFromV8LocalValue(
|
has_instance = v8impl::JsValueFromV8LocalValue(
|
||||||
v8::Local<v8::Value>::New(env->isolate, env->has_instance));
|
v8::Local<v8::Value>::New(env->isolate, env->has_instance));
|
||||||
if (status != napi_ok) return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_instance) {
|
if (has_instance) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user