Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-09-18 09:30:47 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-09-23 17:02:21 +0300
commit07c331147575bb029da11212ea445e8f0a102f90 (patch)
treeb44b7c515b19cdfc2fcc24b5bb8861458303d5cc
parent141de0cc7f4aaaafce61f991ec9a9cdb25d471e0 (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.c8
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);
}
}