From 4c4843605bc6c3b88fe1b342e96153b1f002e3e5 Mon Sep 17 00:00:00 2001 From: wujianlin Date: Tue, 29 Oct 2024 11:32:50 +0800 Subject: [PATCH] cherry pick 37c61b2 from https://gitee.com/chenkeyu13/commonlibrary_c_utils/pulls/463 Increases the supersize check of the returned value Issue:https://gitee.com/openharmony/commonlibrary_c_utils/issues/IB0GRW?from=project-issue Signed-off-by: wujianlin --- base/src/unicode_ex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/unicode_ex.cpp b/base/src/unicode_ex.cpp index ff455be..79854cc 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; } -- Gitee