diff --git a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp index f7d5e5362517aaedc7cf73f8e4e1851c6c097db4..a4550492dd61a058a98f544582285ae6887ae767 100644 --- a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp @@ -1538,6 +1538,9 @@ std::shared_ptr InputMethodController::GetAgent() void InputMethodController::PrintLogIfAceTimeout(int64_t start) { int64_t end = duration_cast(system_clock::now().time_since_epoch()).count(); + if (end < start || start < 0) { + return; + } if (end - start > ACE_DEAL_TIME_OUT) { IMSA_HILOGW("timeout: [%{public}" PRId64 ", %{public}" PRId64 "].", start, end); } diff --git a/services/src/full_ime_info_manager.cpp b/services/src/full_ime_info_manager.cpp index bd00b0ed135277ce35b07bf56c1c61f11b87e84c..eb2d26ee306f2ba8a1438f3297f23128fcf59194 100644 --- a/services/src/full_ime_info_manager.cpp +++ b/services/src/full_ime_info_manager.cpp @@ -40,9 +40,16 @@ FullImeInfoManager::FullImeInfoManager() timerId_ = timer_.Register( []() { Message *msg = new (std::nothrow) Message(MessageID::MSG_ID_REGULAR_UPDATE_IME_INFO, nullptr); - if (msg != nullptr) { - MessageHandler::Instance()->SendMessage(msg); + if (msg == nullptr) { + IMSA_HILOGE("failed to create message!"); + return; } + auto instance = MessageHandler::Instance(); + if (instance == nullptr) { + delete msg; + return; + } + instance->SendMessage(msg); }, TIMER_TASK_INTERNAL, false); } diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index caac6c8c682e036820073c5eb6ef8a8b56511e5e..71791e9f48b7620fb0e4008426ea9fd25a7a703d 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -86,9 +86,14 @@ InputMethodSystemAbility::~InputMethodSystemAbility() { stop_ = true; Message *msg = new (std::nothrow) Message(MessageID::MSG_ID_QUIT_WORKER_THREAD, nullptr); + if (msg == nullptr) { + IMSA_HILOGE("new Message failed"); + return; + } auto handler = MessageHandler::Instance(); if (handler == nullptr) { IMSA_HILOGE("handler is nullptr"); + delete msg; return; } handler->SendMessage(msg);