From 65b0d5be818aa301d7d1291f1c29a5c60a7e3aa7 Mon Sep 17 00:00:00 2001 From: wuchengwen Date: Wed, 6 Aug 2025 19:14:40 +0800 Subject: [PATCH] fix:warning Signed-off-by: wuchengwen --- .../src/input_method_controller.cpp | 3 +++ services/src/full_ime_info_manager.cpp | 11 +++++++++-- services/src/input_method_system_ability.cpp | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/frameworks/native/inputmethod_controller/src/input_method_controller.cpp b/frameworks/native/inputmethod_controller/src/input_method_controller.cpp index f7d5e5362..a4550492d 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 bd00b0ed1..eb2d26ee3 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 caac6c8c6..71791e9f4 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); -- Gitee