[Bf-blender-cvs] [be73170] master: Fix UI crash entering very long strings
Campbell Barton
noreply at git.blender.org
Fri Sep 18 11:59:41 CEST 2015
Commit: be73170bf639d0bf3e6f69bc8d1d40f83cd4fa92
Author: Campbell Barton
Date: Fri Sep 18 16:30:47 2015 +1000
Branches: master
https://developer.blender.org/rBbe73170bf639d0bf3e6f69bc8d1d40f83cd4fa92
Fix UI crash entering very long strings
Strings exceeding UI_MAX_DRAW_STR weren't null terminated.
===================================================================
M source/blender/editors/interface/interface.c
===================================================================
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 5a70dc8..7802161 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);
}
}
More information about the Bf-blender-cvs
mailing list