aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/text.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-09 20:53:26 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-09 20:53:26 -0400
commitcd63679126ecef4b2f65446c2090c8c2a6cfdc5e (patch)
tree5f71774f865a4b9d514b476b37a12d21919f7521 /src/stdlib/text.c
parent23d99b993af8cf4e58f6335b10adec4a2911b192 (diff)
Fix memory leak/bug
Diffstat (limited to 'src/stdlib/text.c')
-rw-r--r--src/stdlib/text.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/stdlib/text.c b/src/stdlib/text.c
index 0c1538ff..76377321 100644
--- a/src/stdlib/text.c
+++ b/src/stdlib/text.c
@@ -521,7 +521,7 @@ static Text_t concat2(Text_t a, Text_t b) {
}
OptionalText_t glue =
- Text$from_utf32((List_t){.data = norm_buf, .length = (int64_t)norm_length, .stride = sizeof(int32_t)});
+ Text$from_utf32((List_t){.data = normalized, .length = (int64_t)norm_length, .stride = sizeof(int32_t)});
assert(glue.length >= 0);
if (normalized != norm_buf) free(normalized);
@@ -1575,8 +1575,9 @@ List_t Text$utf16(Text_t text) {
size_t u16_len = sizeof(u16_buf) / sizeof(u16_buf[0]);
uint16_t *chunk_u16 = u32_to_u16(utf32.data + utf32.stride * i, 1, u16_buf, &u16_len);
if (chunk_u16 == NULL) fail("Invalid codepoints encountered!");
- List$insert_all(&utf16, (List_t){.data = u16_buf, .stride = sizeof(uint16_t), .length = (int64_t)u16_len}, I(0),
- sizeof(uint16_t));
+ List$insert_all(&utf16, (List_t){.data = chunk_u16, .stride = sizeof(uint16_t), .length = (int64_t)u16_len},
+ I(0), sizeof(uint16_t));
+ if (chunk_u16 != u16_buf) free(chunk_u16);
}
return utf16;
}