diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index 030ad44cac5105e471ee5a7dff09da2ca3cc74a1..3e27628ca469108e57fd59b32f06f88154846979 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 5d867df32ab94cc1df52131e21fccc39f3715336..887cb62748499d5983f8c8a202aaedc292e4ec1a 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 ed6aa0aa3a82949f1d1c388667022de83a10e9ab..6a9a7b9d010606887aee0ac791b5d7ebba06723f 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 b94e27a7926f33c2a6f28c0fe5b16d13ce0bd15e..e9d4dcf4783c6a9434ff23865f5e89d71ac08aa6 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 943dd3d9aa21d387fd4e392ea57a5f442dd1fe9b..4dcf84e08fdba42dc5dad8632f0d56d4981010c2 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 ce741a77ff15e96e071bcaf01f1946323a6808d0..4b1134b17f9c727f7064534437746e59aedd695d 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 043b327f50fc2e2a65aee4f4ad8fb9b6a1940626..0c9b85de00e8d2f4ecedec1794322f80debedeba 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());