From 2e0d2f05b7dd65a2ab38133f13c5c6d7a616b8c0 Mon Sep 17 00:00:00 2001 From: cy7717 Date: Tue, 9 Jul 2024 09:40:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E5=89=8D=E5=AD=90?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=8E=B7=E5=8F=96=E4=B8=BA=E7=A9=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cy7717 --- services/src/ime_info_inquirer.cpp | 12 ++++++++++-- services/src/input_method_system_ability.cpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/services/src/ime_info_inquirer.cpp b/services/src/ime_info_inquirer.cpp index 676d7283..d44561ad 100644 --- a/services/src/ime_info_inquirer.cpp +++ b/services/src/ime_info_inquirer.cpp @@ -444,11 +444,15 @@ int32_t ImeInfoInquirer::GetSubProperty(int32_t userId, const std::string &subNa const std::vector &extInfos, SubProperty &subProp) { IMSA_HILOGD("oldIme, userId: %{public}d", userId); + if (extInfos.empty()) { + IMSA_HILOGE("extInfos is empty"); + return ErrorCode::ERROR_PACKAGE_MANAGER; + } auto extInfo = std::find_if(extInfos.begin(), extInfos.end(), [&subName](const ExtensionAbilityInfo &info) { return info.name == subName; }); if (extInfo == extInfos.end()) { IMSA_HILOGE("subtype %{public}s not found", subName.c_str()); - return ErrorCode::ERROR_BAD_PARAMETERS; + extInfo = extInfos.begin(); } subProp.labelId = extInfo->labelId; subProp.label = GetStringById(extInfo->bundleName, extInfo->moduleName, extInfo->labelId, userId); @@ -496,11 +500,15 @@ int32_t ImeInfoInquirer::GetSubProperty(int32_t userId, const std::string &subNa IMSA_HILOGE("failed to parse subtype"); return ret; } + if (subtypes.empty()) { + IMSA_HILOGE("subtypes is empty"); + return ErrorCode::ERROR_PACKAGE_MANAGER; + } auto subtype = std::find_if( subtypes.begin(), subtypes.end(), [&subName](const Subtype &subtype) { return subtype.id == subName; }); if (subtype == subtypes.end()) { IMSA_HILOGE("subtype %{public}s not found", subName.c_str()); - return ErrorCode::ERROR_BAD_PARAMETERS; + subtype = subtypes.begin(); } subProp.label = subtype->label; subProp.name = extInfo.bundleName; diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 490dd03d..0442ad87 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -884,7 +884,7 @@ int32_t InputMethodSystemAbility::OnUserStarted(const Message *msg) int32_t InputMethodSystemAbility::OnUserRemoved(const Message *msg) { - if (msg != nullptr || msg->msgContent_ == nullptr) { + if (msg == nullptr || msg->msgContent_ == nullptr) { IMSA_HILOGE("Aborted! Message is nullptr."); return ErrorCode::ERROR_NULL_POINTER; }