From 62ff108c6fe152664db4d5de75368ff81a4bd41c Mon Sep 17 00:00:00 2001 From: niulihua Date: Fri, 12 Mar 2021 00:30:45 -0800 Subject: [PATCH] fix param check Change-Id: I849433d02ee3c13f5939f657d4a681e1d13d4a20 --- frameworks/common/typed_text.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frameworks/common/typed_text.cpp b/frameworks/common/typed_text.cpp index 63e3780..5bbb523 100755 --- a/frameworks/common/typed_text.cpp +++ b/frameworks/common/typed_text.cpp @@ -246,6 +246,9 @@ int16_t TypedText::GetTextWidth(const char* text, uint16_t length, int16_t lette uint8_t TypedText::GetUTF8OneCharacterSize(const char* str) { + if (str == nullptr) { + return 0; + } if ((str[0] & 0x80) == 0) { return 1; } else if ((str[0] & 0xE0) == 0xC0) { @@ -381,4 +384,4 @@ uint32_t TypedText::GetUtf16Cnt(const char* utf8Str) } return len; } -} // namespace OHOS \ No newline at end of file +} // namespace OHOS -- GitLab