From 6f9dedcf5f924b25e9cc2ddaecfa7b3513560eed Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 9 Mar 2024 14:11:11 -0500 Subject: Fix NUL termination bug in text library --- builtins/text.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtins/text.c b/builtins/text.c index 445d5ab0..37ef2e9f 100644 --- a/builtins/text.c +++ b/builtins/text.c @@ -125,6 +125,7 @@ public CORD Text__upper(CORD str) if (!str) return str; size_t len = strlen(str) + 1; uint8_t *dest = GC_MALLOC_ATOMIC(len); + dest[len-1] = 0; return (CORD)u8_toupper((const uint8_t*)str, len-1, uc_locale_language(), NULL, dest, &len); } @@ -133,6 +134,7 @@ public CORD Text__lower(CORD str) if (!str) return str; size_t len = strlen(str) + 1; uint8_t *dest = GC_MALLOC_ATOMIC(len); + dest[len-1] = 0; return (CORD)u8_tolower((const uint8_t*)str, len-1, uc_locale_language(), NULL, dest, &len); } @@ -141,6 +143,7 @@ public CORD Text__title(CORD str) if (!str) return str; size_t len = strlen(str) + 1; uint8_t *dest = GC_MALLOC_ATOMIC(len); + dest[len-1] = 0; return (CORD)u8_totitle((const uint8_t*)str, len-1, uc_locale_language(), NULL, dest, &len); } -- cgit v1.2.3