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; }