diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-28 15:44:55 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-08-28 15:50:52 +0300 |
commit | 457302b67b9de6a92240c2736306cfa01187101d (patch) | |
tree | eaa6c9fc065aa7fd3730270027f121b709e054ac /source/blender/editors | |
parent | 079791dc30571227393db525704baea7540fb5c6 (diff) |
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_console/console_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 763beb8671b..c6fb2560dc0 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -435,7 +435,7 @@ static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *eve } 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); 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); |