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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-01-05 23:38:15 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-01-05 23:38:15 +0300
commitc91e64faa612aabac3f99a0b607d42303f945ac9 (patch)
tree2ec7d93a555af6098b3cb5b055268f67861fb242 /source/blender/editors
parente7a9bf88d2243bead0ed1b5f9db1f21aef7ea397 (diff)
Fix/cleanup very ugly and unsafe usage of but->str in ui_but_update().
Currently, but->str should never be smaller than but->strdata, but code shall not rely on this. Further more, but->strdata is 'only' 128 chars, this could become limit with some translations, if the org label is already rather long, leading to truncated str (Chinese e.g. can only store about 40 chars in strdata).
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e730182ae37..50161863872 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2647,7 +2647,18 @@ void ui_but_update(uiBut *but)
if (RNA_property_enum_name_gettexted(but->block->evil_C,
&but->rnapoin, but->rnaprop, value, &buf))
{
- BLI_strncpy(but->str, buf, sizeof(but->strdata));
+ if (but->str == but->strdata) {
+ if (strlen(buf) < sizeof(but->strdata)) {
+ BLI_strncpy(but->str, buf, sizeof(but->strdata));
+ }
+ else {
+ but->str = BLI_strdup(buf);
+ }
+ }
+ else {
+ MEM_SAFE_FREE(but->str);
+ but->str = BLI_strdup(buf);
+ }
}
}
}