diff --git a/framework/innerkitsimpl/data/unified_data.cpp b/framework/innerkitsimpl/data/unified_data.cpp index cbf3c57de4dedb22877855dc96646f4a4c3c096b..bbb35dd0d91bebe026b061ef39426753aa2e8062 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 8f0306fd00adaae61a2a24839fba161fc3982de4..7af5317fa91eb7795209c161f1923792c126523d 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 905e8cae19068950f9ed8afcdbb889c84130ddfd..f88a80c71dd7aec6f4ddc40f03012799380adc51 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; }