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
committerCampbell Barton <ideasman42@gmail.com>2015-09-18 09:40:54 +0300
commitbe73170bf639d0bf3e6f69bc8d1d40f83cd4fa92 (patch)
tree5a4983528451a11e53687ccc7d4faddf60dde4c1
parentf7239e9084a9465e705b0e6a2e362561fd547515 (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);
}
}