You need to sign in or sign up before continuing.
提交 dfb2308b 编写于 作者: O openharmony_ci 提交者: Gitee

!56 【轻量级 PR】:fix bug of RemoteObject constructor compatibility

Merge pull request !56 from liangshenglin1/N/A
......@@ -62,12 +62,23 @@ napi_value NAPIAshmem::CreateAshmem(napi_env env, napi_callback_info info)
ZLOGE(LOG_LABEL, "type mismatch for parameter 1");
return nullptr;
}
size_t bufferSize = 0;
napi_get_value_string_utf8(env, argv[0], nullptr, 0, &bufferSize);
if (bufferSize <= 0) {
ZLOGE(LOG_LABEL, "invalid ashmem name");
return nullptr;
}
napi_typeof(env, argv[1], &valueType);
if (valueType != napi_number) {
ZLOGE(LOG_LABEL, "type mismatch for parameter 2");
return nullptr;
}
int32_t ashmemSize = 0;
napi_get_value_int32(env, argv[1], &ashmemSize);
if (ashmemSize <= 0) {
ZLOGE(LOG_LABEL, "invalid ashmem size");
return nullptr;
}
napi_value global = nullptr;
napi_status status = napi_get_global(env, &global);
NAPI_ASSERT(env, status == napi_ok, "get napi global failed");
......
......@@ -395,12 +395,12 @@ napi_value NAPIRemoteObjectHolder::queryLocalInterface(std::string &descriptor)
napi_value RemoteObject_JS_Constructor(napi_env env, napi_callback_info info)
{
// new napi remote object
size_t argc = 1;
size_t argc = 2;
size_t expectedArgc = 1;
napi_value argv[1] = { 0 };
napi_value argv[2] = { 0 };
napi_value thisVar = nullptr;
napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr);
NAPI_ASSERT(env, argc == expectedArgc, "requires 1 parameters");
NAPI_ASSERT(env, argc >= expectedArgc, "requires at least 1 parameters");
napi_valuetype valueType = napi_null;
napi_typeof(env, argv[0], &valueType);
NAPI_ASSERT(env, valueType == napi_string, "type mismatch for parameter 1");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册