From c2b2e4fe98478e42b3e4bf7ee58e9fcaaa02b8c6 Mon Sep 17 00:00:00 2001 From: lovechinamo Date: Mon, 20 Jun 2022 16:48:26 +0800 Subject: [PATCH] Signed-off-by: lovechinamo Changes to be committed: modified: input_method_controller.cpp --- .../inputmethod_controller/src/input_method_controller.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/inputmethod_controller/src/input_method_controller.cpp b/frameworks/inputmethod_controller/src/input_method_controller.cpp index 53adcf5..4795055 100644 --- a/frameworks/inputmethod_controller/src/input_method_controller.cpp +++ b/frameworks/inputmethod_controller/src/input_method_controller.cpp @@ -384,8 +384,9 @@ using namespace MessageID; std::u16string InputMethodController::GetTextAfterCursor(int32_t number) { + constexpr unsigned int MAX_INT32_T = 2147483647; IMSA_HILOGI("InputMethodController::GetTextBeforeCursor"); - if (!mTextString.empty()) { + if (!mTextString.empty() && mTextString.size <= MAX_INT32_T) { int32_t endPos = (mSelectNewEnd + number < static_cast(mTextString.size())) ? (mSelectNewEnd + number) : mTextString.size();