diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-09-18 09:30:47 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-09-23 17:02:21 +0300 |
commit | 07c331147575bb029da11212ea445e8f0a102f90 (patch) | |
tree | b44b7c515b19cdfc2fcc24b5bb8861458303d5cc | |
parent | 141de0cc7f4aaaafce61f991ec9a9cdb25d471e0 (diff) |
Fix UI crash entering very long strings
Strings exceeding UI_MAX_DRAW_STR weren't null terminated.
-rw-r--r-- | source/blender/editors/interface/interface.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 5a70dc85530..78021612195 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2156,8 +2156,14 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int str[0] = '\0'; } else if (buf && buf != str) { + BLI_assert(maxlen <= buf_len + 1); /* string was too long, we have to truncate */ - memcpy(str, buf, MIN2(maxlen, (size_t)(buf_len + 1))); + if (ui_but_is_utf8(but)) { + BLI_strncpy_utf8(str, buf, maxlen); + } + else { + BLI_strncpy(str, buf, maxlen); + } MEM_freeN((void *)buf); } } |