From f5a4680980d38b68c7bdc25048c6059e744a5a99 Mon Sep 17 00:00:00 2001 From: 13776621730 Date: Tue, 24 Jun 2025 19:26:11 +0800 Subject: [PATCH] =?UTF-8?q?preview=E9=97=AE=E9=A2=98=E5=92=8C=E6=8E=A8?= =?UTF-8?q?=E5=8C=85=E5=88=B0rk=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 13776621730 --- frameworks/native/runtime/js_runtime.cpp | 2 +- frameworks/native/runtime/js_runtime_lite.cpp | 3 ++- .../ability_simulator/include/bundle_parser/json_util.h | 3 ++- .../ability_simulator/src/bundle_parser/bundle_container.cpp | 5 ++++- .../ability_simulator/src/bundle_parser/json_util.cpp | 2 +- .../ability_simulator/src/bundle_parser/module_profile.cpp | 5 ++++- .../abilitymgr/src/ability_auto_startup_data_manager.cpp | 2 +- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index 030ad44cac5..3e27628ca46 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -1698,7 +1698,7 @@ std::vector JsRuntime::GetSystemKitsMap(uint32_t version) return systemKitsMap; } cJSON *systemKitsItem = cJSON_GetObjectItem(jsonBuf, SYSTEM_KITS.c_str()); - if (systemKitsItem == nullptr || !cJSON_IsArray(systemKitsItem)) { + if (systemKitsItem == nullptr) { cJSON_Delete(jsonBuf); return systemKitsMap; } diff --git a/frameworks/native/runtime/js_runtime_lite.cpp b/frameworks/native/runtime/js_runtime_lite.cpp index 5d867df32ab..887cb627484 100644 --- a/frameworks/native/runtime/js_runtime_lite.cpp +++ b/frameworks/native/runtime/js_runtime_lite.cpp @@ -473,7 +473,8 @@ void JsRuntimeLite::GetPkgContextInfoListMap(const std::mapfirst.c_str()); continue; } - std::string jsonStr(reinterpret_cast(data.get(), dataLen)); + const char *str = reinterpret_cast(data.get()); + std::string jsonStr = str == nullptr ? "" : std::string(reinterpret_cast(data.get()), dataLen); cJSON *jsonObject = cJSON_Parse(jsonStr.c_str()); if (jsonObject == nullptr) { TAG_LOGE(AAFwkTag::JSRUNTIME, "moduleName: %{public}s parse json error", it->first.c_str()); diff --git a/frameworks/simulator/ability_simulator/include/bundle_parser/json_util.h b/frameworks/simulator/ability_simulator/include/bundle_parser/json_util.h index ed6aa0aa3a8..6a9a7b9d010 100644 --- a/frameworks/simulator/ability_simulator/include/bundle_parser/json_util.h +++ b/frameworks/simulator/ability_simulator/include/bundle_parser/json_util.h @@ -50,6 +50,7 @@ void GetNumberValueIfFindKey(const cJSON *jsonObject, if (parseResult) { return; } + cJSON *item = cJSON_GetObjectItem(jsonObject, key.c_str()); if (item == nullptr) { if (isNecessary) { @@ -137,7 +138,7 @@ void GetObjectValueIfFindKey(const cJSON *jsonObject, parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR; return; } - from_json(jsonObject, data); + from_json(item, data); } template diff --git a/frameworks/simulator/ability_simulator/src/bundle_parser/bundle_container.cpp b/frameworks/simulator/ability_simulator/src/bundle_parser/bundle_container.cpp index b94e27a7926..e9d4dcf4783 100644 --- a/frameworks/simulator/ability_simulator/src/bundle_parser/bundle_container.cpp +++ b/frameworks/simulator/ability_simulator/src/bundle_parser/bundle_container.cpp @@ -44,7 +44,10 @@ void BundleContainer::LoadBundleInfos(const std::vector &buffer, const bundleInfo_->GetApplicationInfo(0, Constants::UNSPECIFIED_USERID, *appInfo); if (appInfo != nullptr) { std::string bundleName = appInfo->bundleName; - std::string moduleName = appInfo->moduleInfos[0].moduleName; + std::string moduleName; + if (appInfo->moduleInfos.size() > 0) { + moduleName = appInfo->moduleInfos[0].moduleName; + } auto key = bundleName + std::string(FILE_SEPARATOR) + moduleName; bundleInfos_.emplace(key, bundleInfo_); resourcePaths_.emplace(key, resourcePath_); diff --git a/frameworks/simulator/ability_simulator/src/bundle_parser/json_util.cpp b/frameworks/simulator/ability_simulator/src/bundle_parser/json_util.cpp index 943dd3d9aa2..4dcf84e08fd 100644 --- a/frameworks/simulator/ability_simulator/src/bundle_parser/json_util.cpp +++ b/frameworks/simulator/ability_simulator/src/bundle_parser/json_util.cpp @@ -88,7 +88,7 @@ void GetStringValuesIfFindKey(const cJSON *jsonObject, parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR; return; } - if (std::string(item->valuestring).length() > Constants::MAX_JSON_ELEMENT_LENGTH) { + if (std::string(childItem->valuestring).length() > Constants::MAX_JSON_ELEMENT_LENGTH) { TAG_LOGE(AAFwkTag::ABILITY_SIM, "type:%{public}s string length error", key.c_str()); parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_SIZE_CHECK_ERROR; return; diff --git a/frameworks/simulator/ability_simulator/src/bundle_parser/module_profile.cpp b/frameworks/simulator/ability_simulator/src/bundle_parser/module_profile.cpp index ce741a77ff1..4b1134b17f9 100644 --- a/frameworks/simulator/ability_simulator/src/bundle_parser/module_profile.cpp +++ b/frameworks/simulator/ability_simulator/src/bundle_parser/module_profile.cpp @@ -1105,24 +1105,27 @@ ErrCode ModuleProfile::TransformTo(const std::vector &buf, InnerBundleI Profile::ModuleJson moduleJson; from_json(jsonObject, moduleJson); - cJSON_Delete(jsonObject); if (Profile::g_parseResult != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITY_SIM, "g_parseResult:%{public}d", Profile::g_parseResult); int32_t ret = Profile::g_parseResult; // need recover parse result to ERR_OK Profile::g_parseResult = ERR_OK; + cJSON_Delete(jsonObject); return ret; } if (!ToInnerBundleInfo(moduleJson, innerBundleInfo)) { + cJSON_Delete(jsonObject); return ERR_APPEXECFWK_PARSE_PROFILE_PROP_CHECK_ERROR; } if (!ParserAtomicConfig(jsonObject, innerBundleInfo)) { TAG_LOGE(AAFwkTag::ABILITY_SIM, "Parser atomicService config failed"); + cJSON_Delete(jsonObject); return ERR_APPEXECFWK_PARSE_PROFILE_PROP_CHECK_ERROR; } + cJSON_Delete(jsonObject); return ERR_OK; } } // namespace AppExecFwk diff --git a/services/abilitymgr/src/ability_auto_startup_data_manager.cpp b/services/abilitymgr/src/ability_auto_startup_data_manager.cpp index 043b327f50f..0c9b85de00e 100644 --- a/services/abilitymgr/src/ability_auto_startup_data_manager.cpp +++ b/services/abilitymgr/src/ability_auto_startup_data_manager.cpp @@ -554,7 +554,7 @@ void AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromValue( cJSON *isEdmForceItem = cJSON_GetObjectItem(jsonValueObject, JSON_KEY_IS_EDM_FORCE.c_str()); if (isEdmForceItem != nullptr && cJSON_IsBool(isEdmForceItem)) { - info.canUserModify = isEdmForceItem->type == cJSON_True; + info.canUserModify = !(isEdmForceItem->type == cJSON_True); } cJSON *setterUserIdItem = cJSON_GetObjectItem(jsonValueObject, JSON_KEY_SETTER_USERID.c_str()); -- Gitee