Fix UI crash entering very long strings
Strings exceeding UI_MAX_DRAW_STR weren't null terminated.
This commit is contained in:
@@ -2156,8 +2156,14 @@ void ui_but_string_get_ex(uiBut *but, char *str, const size_t maxlen, const int
|
|||||||
str[0] = '\0';
|
str[0] = '\0';
|
||||||
}
|
}
|
||||||
else if (buf && buf != str) {
|
else if (buf && buf != str) {
|
||||||
|
BLI_assert(maxlen <= buf_len + 1);
|
||||||
/* string was too long, we have to truncate */
|
/* 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);
|
MEM_freeN((void *)buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user