diff --git a/src/ports/skia_ohos/FontConfig_ohos.cpp b/src/ports/skia_ohos/FontConfig_ohos.cpp index e522dc46b83fedf21040fd267dec6ae725fd9d0f..523d302d3022fb72afe27e55d21af1864f9212ae 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 95cbf0ed04d60f98f3966bad51ca50fc0cea2e9b..484b98cd0192463b1227fe94d98162c129de8b4c 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