From 0b7ca098ae1dc5e31485bc505a441d3796f0702b Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 4 Mar 2024 01:34:12 -0500 Subject: Fix some bugs relating to NUL termination of strings --- compile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 79a92e0d..115ac701 100644 --- a/compile.c +++ b/compile.c @@ -173,7 +173,7 @@ CORD compile(env_t *env, ast_t *ast) switch (value_type(t)->tag) { case TextType: { CORD str = compile_to_pointer_depth(env, expr, 0, false); - return CORD_all("CORD_len(", str, ")"); + return CORD_all("Text__num_clusters(", str, ")"); } case ArrayType: { if (t->tag == PointerType) { @@ -860,8 +860,9 @@ CORD compile(env_t *env, ast_t *ast) if (test->output) { const uint8_t *raw = (const uint8_t*)CORD_to_const_char_star(test->output); uint8_t buf[128] = {0}; - size_t norm_len = sizeof(buf)-1; - uint8_t *norm = u8_normalize(UNINORM_NFD, (uint8_t*)raw, strlen((char*)raw), buf, &norm_len); + size_t norm_len = sizeof(buf); + uint8_t *norm = u8_normalize(UNINORM_NFD, (uint8_t*)raw, strlen((char*)raw)+1, buf, &norm_len); + assert(norm[norm_len-1] == 0); output = CORD_from_char_star((char*)norm); if (norm && norm != buf) free(norm); } -- cgit v1.2.3