Skip to content

Commit 9ad2057

Browse files
committed
napi_is_buffer should not return error when called with a non-TypedArray
1 parent 898016f commit 9ad2057

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/node_jsrtapi.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,8 +1358,14 @@ napi_status napi_create_buffer_copy(napi_env e,
13581358
napi_status napi_is_buffer(napi_env e, napi_value v, bool* result) {
13591359
CHECK_ARG(result);
13601360
JsValueRef typedArray = reinterpret_cast<JsValueRef>(v);
1361+
JsValueType objectType;
1362+
CHECK_JSRT(JsGetValueType(typedArray, &objectType));
1363+
if (objectType != JsTypedArray) {
1364+
*result = false;
1365+
return napi_ok;
1366+
}
13611367
JsTypedArrayType arrayType;
1362-
CHECK_JSRT(JsGetTypedArrayInfo(typedArray, &arrayType, nullptr, nullptr, nullptr));
1368+
JsErrorCode code = JsGetTypedArrayInfo(typedArray, &arrayType, nullptr, nullptr, nullptr);
13631369
*result = (arrayType == JsArrayTypeUint8);
13641370
return napi_ok;
13651371
}

0 commit comments

Comments
 (0)