From ac6197f453e025ebf3c8493e230ba0a1f44ca7c3 Mon Sep 17 00:00:00 2001 From: LiFeng Date: Thu, 10 Oct 2024 19:45:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E5=87=BD=E6=95=B0=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LiFeng Change-Id: Ida8030b00612196ec3df2f148841937457ee65c1 --- src/ports/skia_ohos/FontConfig_ohos.cpp | 15 ++++++--------- src/ports/skia_ohos/FontInfo_ohos.h | 5 +++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ports/skia_ohos/FontConfig_ohos.cpp b/src/ports/skia_ohos/FontConfig_ohos.cpp index e522dc46..530ee23d 100755 --- a/src/ports/skia_ohos/FontConfig_ohos.cpp +++ b/src/ports/skia_ohos/FontConfig_ohos.cpp @@ -322,7 +322,7 @@ char* FontConfig_OHOS::getFileData(const char* fname, int& size) fclose(fp); return nullptr; } - memset(data, 0, size); + (void) memset_s(data, size, 0, size); (void) fread(data, size, 1, fp); fclose(fp); return (char*)data; @@ -1037,15 +1037,12 @@ int FontConfig_OHOS::scanFonts(const SkTypeface_FreeType::Scanner& fontScanner) strncmp(fname + len - suffixLen, ".otc", suffixLen))) { continue; } - len += (fontDirSet[i].size() + 2); // 2 more characters for '/' and '\0' - char fullname[len]; - memset(fullname, 0, len); - strcpy(fullname, fontDirSet[i].c_str()); - if (fontDirSet[i][fontDirSet[i].size() - 1] != '/') { - strcat(fullname, "/"); + SkString fullname = fontDirSet[i]; + if (fullname[fullname.size()-1] != '/') { + fullname.append("/"); } - strcat(fullname, fname); - loadFont(fontScanner, fullname); + fullname.append(fname); + loadFont(fontScanner, fullname.c_str()); } closedir(dir); } diff --git a/src/ports/skia_ohos/FontInfo_ohos.h b/src/ports/skia_ohos/FontInfo_ohos.h index fd0db3d0..4a0cfcd6 100755 --- a/src/ports/skia_ohos/FontInfo_ohos.h +++ b/src/ports/skia_ohos/FontInfo_ohos.h @@ -10,6 +10,7 @@ #include "include/private/base/SkFixed.h" #include "src/core/SkFontDescriptor.h" #include "src/ports/SkFontHost_FreeType_common.h" +#include "third_party/bounds_checking_function/include/securec.h" /*! * \brief To manage the font information @@ -22,7 +23,7 @@ public: FontInfo() : familyName(""), fname(""), index(0), style(SkFontStyle::Normal()), isFixedWidth(false), stream(nullptr) { - memset(&axisSet, 0, sizeof(AxisSet)); + (void) memset_s(&axisSet, sizeof(axisSet), 0, sizeof(AxisSet)); } /*! Copy Constructor * \param font an object of FontInfo @@ -63,7 +64,7 @@ public: if (fname) { this->fname.set(fname); } - memset(&axisSet, 0, sizeof(axisSet)); + (void) memset_s(&axisSet, sizeof(axisSet), 0, sizeof(axisSet)); } /*! Destructor -- Gitee