mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-11-27 01:51:13 +00:00
!1303 添加判空、readByteArray增加读校验、去除多余参数
Merge pull request !1303 from Lixiaoying25/master
This commit is contained in:
commit
7ee76f655f
@ -127,7 +127,7 @@ private:
|
||||
static bool JS_WriteRawDataForTypedArray(napi_env env, napi_value jsTypedArray,
|
||||
size_t size, NAPI_MessageSequence *napiSequence);
|
||||
static napi_value JS_checkWriteArrayBufferArgs(napi_env env, size_t argc, napi_value* argv);
|
||||
static bool JS_writeVectorByTypeCode(napi_env env, int32_t typeCode, void *data,
|
||||
static bool JS_writeVectorByTypeCode(int32_t typeCode, void *data,
|
||||
size_t byteLength, NAPI_MessageSequence *napiSequence);
|
||||
static napi_value JS_readVectorByTypeCode(napi_env env, int32_t typeCode, NAPI_MessageSequence *napiSequence);
|
||||
|
||||
|
@ -398,6 +398,7 @@ napi_value NAPI_MessageSequence::JS_readByteArray(napi_env env, napi_callback_in
|
||||
uint32_t arrayLength = napiSequence->nativeParcel_->ReadUint32();
|
||||
|
||||
if (argc > 0) {
|
||||
CHECK_READ_LENGTH(env, (size_t)arrayLength, BYTE_SIZE_8, napiSequence);
|
||||
napi_value argv[ARGV_LENGTH_1] = {0};
|
||||
napi_value checkArgsResult = JS_checkReadArrayArgs(env, info, argc, thisVar, argv);
|
||||
if (checkArgsResult == nullptr) {
|
||||
|
@ -1932,7 +1932,7 @@ napi_value NAPI_MessageSequence::JS_writeArrayBuffer(napi_env env, napi_callback
|
||||
int32_t typeCode = 0;
|
||||
napi_get_value_int32(env, argv[ARGV_INDEX_1], &typeCode);
|
||||
|
||||
bool writeSuccess = JS_writeVectorByTypeCode(env, typeCode, data, byteLength, napiSequence);
|
||||
bool writeSuccess = JS_writeVectorByTypeCode(typeCode, data, byteLength, napiSequence);
|
||||
if (!writeSuccess) {
|
||||
ZLOGE(LOG_LABEL, "write buffer failed");
|
||||
return napiErr.ThrowError(env, errorDesc::WRITE_DATA_TO_MESSAGE_SEQUENCE_ERROR);
|
||||
@ -1943,8 +1943,7 @@ napi_value NAPI_MessageSequence::JS_writeArrayBuffer(napi_env env, napi_callback
|
||||
return napiValue;
|
||||
}
|
||||
|
||||
bool NAPI_MessageSequence::JS_writeVectorByTypeCode(napi_env env,
|
||||
int32_t typeCode,
|
||||
bool NAPI_MessageSequence::JS_writeVectorByTypeCode(int32_t typeCode,
|
||||
void *data,
|
||||
size_t byteLength,
|
||||
NAPI_MessageSequence *napiSequence)
|
||||
|
@ -396,16 +396,18 @@ napi_value NAPIRemoteObject::CatchCallback(napi_env env, napi_callback_info info
|
||||
napi_value argv[ARGV_LENGTH_1] = {nullptr};
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, &data);
|
||||
napi_value res;
|
||||
CallbackParam *param = static_cast<CallbackParam *>(data);
|
||||
if (param == NULL) {
|
||||
ZLOGI(LOG_LABEL, "param is null");
|
||||
if (param == nullptr) {
|
||||
ZLOGE(LOG_LABEL, "param is null");
|
||||
napi_get_undefined(env, &res);
|
||||
return res;
|
||||
}
|
||||
NAPI_RemoteObject_resetOldCallingInfo(param->env, g_oldCallingInfo);
|
||||
param->result = ERR_UNKNOWN_TRANSACTION;
|
||||
std::unique_lock<std::mutex> lock(param->lockInfo->mutex);
|
||||
param->lockInfo->ready = true;
|
||||
param->lockInfo->condition.notify_all();
|
||||
napi_value res;
|
||||
napi_get_undefined(env, &res);
|
||||
return res;
|
||||
}
|
||||
@ -800,6 +802,10 @@ napi_value NAPI_ohos_rpc_CreateJsRemoteObject(napi_env env, const sptr<IRemoteOb
|
||||
status = napi_new_instance(env, constructor, 0, nullptr, &jsRemoteProxy);
|
||||
NAPI_ASSERT(env, status == napi_ok, "failed to construct js RemoteProxy");
|
||||
NAPIRemoteProxyHolder *proxyHolder = NAPI_ohos_rpc_getRemoteProxyHolder(env, jsRemoteProxy);
|
||||
if (proxyHolder == nullptr) {
|
||||
ZLOGE(LOG_LABEL, "proxyHolder null");
|
||||
return nullptr;
|
||||
}
|
||||
proxyHolder->object_ = target;
|
||||
proxyHolder->list_ = new NAPIDeathRecipientList();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user