From e4f42942336068630dc75a2f48d5dac7cd30c1d0 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Thu, 20 Nov 2025 00:41:21 +0100 Subject: [PATCH] strlen => strnlen --- wled00/src/font/unicodetool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/src/font/unicodetool.cpp b/wled00/src/font/unicodetool.cpp index 0fcb9cc8..0fe775c1 100644 --- a/wled00/src/font/unicodetool.cpp +++ b/wled00/src/font/unicodetool.cpp @@ -15,7 +15,7 @@ static inline bool isValidContinuation(unsigned char byte) { uint16_t unicodeToWchar16(const unsigned char* utf8, size_t maxLen) { if (!utf8 || (maxLen < 1) || *utf8 == '\0') return 0; // sanity check - size_t length = strlen((const char*) utf8); + size_t length = strnlen((const char*) utf8, maxLen); length = min(length, maxLen); if (length < 1) return 0; // sanity check @@ -48,7 +48,7 @@ uint16_t unicodeToWchar16(const unsigned char* utf8, size_t maxLen) { // return nullptr at end of input const unsigned char* nextUnicode(const unsigned char* utf8, size_t maxLen) { if ((!utf8) || (maxLen < 1) || (*utf8 == 0)) return nullptr; // sanity check - size_t length = strlen((const char*) utf8); // safe, because utf8 is a C string with proper NUL termination + size_t length = strnlen((const char*) utf8, maxLen); length = min(length, maxLen); if (length < 1) return nullptr; // we are at end of input