diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp index ead7667356dce0e40031147edf7f14a7c99ab212..049fee247885f3f745a8e67a035544f77792b692 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_icon_rdb.cpp @@ -366,6 +366,10 @@ bool BundleResourceIconRdb::ConvertToLauncherAbilityResourceInfo( static_cast(ResourceFlag::GET_RESOURCE_INFO_ALL)); if (getIcon) { ret = absSharedResultSet->GetString(INDEX_ICON, launcherAbilityResourceInfo.icon); + if (launcherAbilityResourceInfo.icon.empty()) { + APP_LOGE("icon is empty"); + return false; + } CHECK_RDB_RESULT_RETURN_IF_FAIL(ret, "GetString label icon, ret: %{public}d"); } @@ -373,6 +377,10 @@ bool BundleResourceIconRdb::ConvertToLauncherAbilityResourceInfo( == static_cast(ResourceFlag::GET_RESOURCE_INFO_WITH_DRAWABLE_DESCRIPTOR); if (getDrawable) { ret = absSharedResultSet->GetBlob(INDEX_FOREGROUND, launcherAbilityResourceInfo.foreground); + if (launcherAbilityResourceInfo.foreground.empty()) { + APP_LOGE("foreground is empty"); + return false; + } CHECK_RDB_RESULT_RETURN_IF_FAIL(ret, "GetBlob foreground, ret: %{public}d"); ret = absSharedResultSet->GetBlob(INDEX_BACKGROUND, launcherAbilityResourceInfo.background); diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp index 9e411664437609bb4f0ab9a4368f50f782b1b6dd..0a6b889cf143f7e120d1009b398d179e1d820fd5 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp @@ -592,7 +592,11 @@ bool BundleResourceParser::ParseIconResourceInfosWithTheme( APP_LOGW_NOFUNC("ParseResourceInfo fail key:%{public}s", resourceInfos[index].GetKey().c_str()); } } - if (resourceInfos[0].icon_.empty()) { + bool invalidIcon = std::all_of(resourceInfos.begin(), resourceInfos.end(), + [](const auto& resourceInfo) { + return resourceInfo.icon_.empty(); + }); + if (invalidIcon) { APP_LOGE_NOFUNC("ParseResourceInfos fail -n %{public}s -m %{public}s", resourceInfos[0].bundleName_.c_str(), resourceInfos[0].moduleName_.c_str()); return false;