Fix UI crash entering very long strings
Strings exceeding UI_MAX_DRAW_STR weren't null terminated.
This commit is contained in:
parent
f7239e9084
commit
be73170bf6
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue