From 31abe47a7510c11159be0c0086c4b466cae7b909 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 8 Jan 2024 23:14:17 +0900 Subject: [PATCH] ttf: Fixed an invalid unicode encoding. Ensured the data count is correctly multiplied by the data size. --- src/loaders/ttf/tvgTtfLoader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/loaders/ttf/tvgTtfLoader.cpp b/src/loaders/ttf/tvgTtfLoader.cpp index e86405b2..b0e028e5 100644 --- a/src/loaders/ttf/tvgTtfLoader.cpp +++ b/src/loaders/ttf/tvgTtfLoader.cpp @@ -125,7 +125,7 @@ static uint32_t* _codepoints(const char* text, size_t n) auto utf8 = text; //preserve approximate enough space. - auto utf32 = (uint32_t*) malloc(sizeof(uint32_t) * n + 1); + auto utf32 = (uint32_t*) malloc(sizeof(uint32_t) * (n + 1)); while(*utf8) { if (!(*utf8 & 0x80U)) { @@ -148,7 +148,7 @@ static uint32_t* _codepoints(const char* text, size_t n) return nullptr; } } - utf32[i - 1] = 0; //end of the unicdoe + utf32[i] = 0; //end of the unicdoe return utf32; }