diff --git a/services/src/input_method_system_ability.cpp b/services/src/input_method_system_ability.cpp index 7c7c6e8..aa9ab40 100644 --- a/services/src/input_method_system_ability.cpp +++ b/services/src/input_method_system_ability.cpp @@ -208,12 +208,14 @@ namespace MiscServices { std::map::const_iterator it = msgHandlers.find(MAIN_USER_ID); if (it == msgHandlers.end()) { IMSA_HILOGE("InputMethodSystemAbility::StartInputService() need start handler"); - sptr handler = new MessageHandler(); + MessageHandler *handler = new MessageHandler(); if (session) { IMSA_HILOGE("InputMethodSystemAbility::OnPrepareInput session is not nullptr"); session->CreateWorkThread(*handler); msgHandlers.insert(std::pair(MAIN_USER_ID, handler)); } + delete handler; + handler = nullptr; } bool isStartSuccess = false;