Skip to content

Commit 4a0e7d5

Browse files
authored
Merge pull request #121 from boingoing/fix_napi_is_buffer
napi_is_buffer should not return an error code when it's called with a non-TypedArray object
2 parents 898016f + 2bb22e0 commit 4a0e7d5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/node_jsrtapi.cc

+6
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,12 @@ 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;
13621368
CHECK_JSRT(JsGetTypedArrayInfo(typedArray, &arrayType, nullptr, nullptr, nullptr));
13631369
*result = (arrayType == JsArrayTypeUint8);

0 commit comments

Comments
 (0)