diff --git a/base/src/unicode_ex.cpp b/base/src/unicode_ex.cpp index ff455be6a3cabc317b30aa4f09ccab57980e372a..79854cc440c588e408ae729ffbd99eab86479ecb 100644 --- a/base/src/unicode_ex.cpp +++ b/base/src/unicode_ex.cpp @@ -330,7 +330,7 @@ char16_t* Char8ToChar16(const char* str8, size_t str8Len) { char16_t* str16 = nullptr; int utf16Len = Utf8ToUtf16Length(str8, str8Len); - if (utf16Len < 0) { + if (utf16Len < 0 || utf16Len >= INT_MAX) { UTILS_LOGE("Get str16 length failed,length is: %{public}d", utf16Len); return nullptr; }