From ca3035208a88fd543f1f8902226f0bb4b59f386d Mon Sep 17 00:00:00 2001 From: wanxiaoqing Date: Wed, 11 Dec 2024 17:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wanxiaoqing --- framework/innerkitsimpl/data/unified_data.cpp | 4 ++++ framework/jskitsimpl/common/napi_data_utils.cpp | 4 ++-- framework/jskitsimpl/data/unified_data_napi.cpp | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/framework/innerkitsimpl/data/unified_data.cpp b/framework/innerkitsimpl/data/unified_data.cpp index cbf3c57..bbb35dd 100755 --- a/framework/innerkitsimpl/data/unified_data.cpp +++ b/framework/innerkitsimpl/data/unified_data.cpp @@ -194,6 +194,10 @@ void UnifiedData::SetProperties(std::shared_ptr propertie LOG_ERROR(UDMF_FRAMEWORK, "properties is null!"); return; } + if (properties_ == nullptr) { + LOG_ERROR(UDMF_FRAMEWORK, "properties_ is nullptr!"); + return; + } properties->timestamp = properties_->timestamp; properties_ = properties; } diff --git a/framework/jskitsimpl/common/napi_data_utils.cpp b/framework/jskitsimpl/common/napi_data_utils.cpp index 8f0306f..7af5317 100644 --- a/framework/jskitsimpl/common/napi_data_utils.cpp +++ b/framework/jskitsimpl/common/napi_data_utils.cpp @@ -376,8 +376,8 @@ napi_status NapiDataUtils::GetValue(napi_env env, napi_value in, std::shared_ptr napi_status status = napi_typeof(env, in, &type); LOG_ERROR_RETURN((status == napi_ok) && (type == napi_object), "invalid type", napi_invalid_arg); TypeDescriptorNapi *descriptorNapi = nullptr; - napi_unwrap(env, in, reinterpret_cast(&descriptorNapi)); - LOG_ERROR_RETURN((descriptorNapi != nullptr), "invalid type", napi_invalid_arg); + auto unwrap = napi_unwrap(env, in, reinterpret_cast(&descriptorNapi)); + LOG_ERROR_RETURN((descriptorNapi != nullptr || unwrap == napi_ok), "invalid type", napi_invalid_arg); descriptor = descriptorNapi->value_; if (descriptor == nullptr) { LOG_DEBUG(UDMF_KITS_NAPI, "napi_value -> GetValue TypeDescriptor failed "); diff --git a/framework/jskitsimpl/data/unified_data_napi.cpp b/framework/jskitsimpl/data/unified_data_napi.cpp index 905e8ca..f88a80c 100644 --- a/framework/jskitsimpl/data/unified_data_napi.cpp +++ b/framework/jskitsimpl/data/unified_data_napi.cpp @@ -78,6 +78,9 @@ napi_value UnifiedDataNapi::New(napi_env env, napi_callback_info info) UnifiedDataPropertiesNapi::Constructor(env)); if (propertiesNapi == nullptr) { LOG_ERROR(UDMF_KITS_NAPI, "new UnifiedDataPropertiesNapi failed!"); + if (uData->propertyRef_ != nullptr) { + napi_delete_reference(env, uData->propertyRef_); + } delete(uData); return nullptr; } -- Gitee