diff --git a/old/services/core/src/devicemanager/dp_device_manager.cpp b/old/services/core/src/devicemanager/dp_device_manager.cpp index 805e7ccd..2890e563 100644 --- a/old/services/core/src/devicemanager/dp_device_manager.cpp +++ b/old/services/core/src/devicemanager/dp_device_manager.cpp @@ -101,7 +101,7 @@ void DpDeviceManager::DpDeviceStateCallback::OnDeviceOnline(const DmDeviceInfo & DistributedDeviceProfileService::GetInstance().DeviceOnline(); std::string networkId = deviceInfo.networkId; DistributedDeviceProfile::ProfileCache::GetInstance().OnNodeOnline(networkId); - DistributedDeviceProfile::DeviceProfileManager::GetInstance().ClearDataOnDeviceOnline( + DistributedDeviceProfile::DeviceProfileManager::GetInstance().FixDataOnDeviceOnline( deviceInfo.networkId, deviceInfo.extraData); } diff --git a/services/core/include/deviceprofilemanager/device_profile_manager.h b/services/core/include/deviceprofilemanager/device_profile_manager.h index bb44fa38..dad7fe48 100644 --- a/services/core/include/deviceprofilemanager/device_profile_manager.h +++ b/services/core/include/deviceprofilemanager/device_profile_manager.h @@ -68,7 +68,7 @@ public: int32_t SavePutTempCache(std::map& entries); bool IsFirstInitDB(); void ResetFirst(); - void ClearDataOnDeviceOnline(const std::string& networkId, const std::string& extraData); + void FixDataOnDeviceOnline(const std::string& networkId, const std::string& extraData); private: bool LoadDpSyncAdapter(); diff --git a/services/core/src/deviceprofilemanager/device_profile_manager.cpp b/services/core/src/deviceprofilemanager/device_profile_manager.cpp index d3bbc687..f7642d78 100644 --- a/services/core/src/deviceprofilemanager/device_profile_manager.cpp +++ b/services/core/src/deviceprofilemanager/device_profile_manager.cpp @@ -608,7 +608,7 @@ void DeviceProfileManager::ResetFirst() isFirst_.store(false); } -void DeviceProfileManager::ClearDataOnDeviceOnline(const std::string& networkId, const std::string& extraData) +void DeviceProfileManager::FixDataOnDeviceOnline(const std::string& networkId, const std::string& extraData) { HILOGI("networkId:%{public}s", ProfileUtils::GetAnonyString(networkId).c_str()); if (networkId.empty() || extraData.empty()) { @@ -623,9 +623,12 @@ void DeviceProfileManager::ClearDataOnDeviceOnline(const std::string& networkId, } int32_t osType = DEFAULT_OS_TYPE; cJSON* osTypeJson = cJSON_GetObjectItem(extraDataJson, DistributedHardware::PARAM_KEY_OS_TYPE); - if (cJSON_IsNumber(osTypeJson)) { - osType = static_cast(osTypeJson->valueint); + if (!cJSON_IsNumber(osTypeJson)) { + HILOGE("osTypeJson is not a number"); + cJSON_Delete(extraDataJson); + return; } + osType = static_cast(osTypeJson->valueint); cJSON_Delete(extraDataJson); if (osType != DEFAULT_OS_TYPE) { return;