[Bf-blender-cvs] [07c3311] blender-v2.76-release: Fix UI crash entering very long strings

Campbell Barton noreply at git.blender.org
Wed Sep 23 16:11:46 CEST 2015


Commit: 07c331147575bb029da11212ea445e8f0a102f90
Author: Campbell Barton
Date:   Fri Sep 18 16:30:47 2015 +1000
Branches: blender-v2.76-release
https://developer.blender.org/rB07c331147575bb029da11212ea445e8f0a102f90

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