diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 14:11:11 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 14:11:11 -0500 |
| commit | 6f9dedcf5f924b25e9cc2ddaecfa7b3513560eed (patch) | |
| tree | 3f78be16d27886ada235ce7680bceef7e8450ebe | |
| parent | 1627a913a44bd197fecfc59111f156943563c5ea (diff) | |
Fix NUL termination bug in text library
| -rw-r--r-- | builtins/text.c | 3 |
1 files changed, 3 insertions, 0 deletions
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); } |
