From 457302b67b9de6a92240c2736306cfa01187101d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 28 Aug 2021 22:44:55 +1000 Subject: BLI_string_utf8: add buffer size arg to BLI_str_utf8_from_unicode Besides helping to avoid buffer overflow errors this reduces complexity of BLI_str_utf32_as_utf8 which needed a special loop for the last 6 characters to avoid writing past the buffer bounds. Also add BLI_str_utf8_from_unicode_len which only returns the length. --- source/blender/editors/space_text/text_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/editors/space_text') diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index b7185766224..c3bc474b98a 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3486,7 +3486,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event) } else { /* in theory, ghost can set value to extended ascii here */ - len = BLI_str_utf8_from_unicode(event->ascii, str); + len = BLI_str_utf8_from_unicode(event->ascii, str, sizeof(str) - 1); } str[len] = '\0'; RNA_string_set(op->ptr, "text", str); -- cgit v1.2.3