BLF: String length to cursor position, not INT_MAX
BLF_str_offset_from_cursor_position is being called with a str_len of INT_MAX, so max buffer size instead of string length. This works fine right now but will not when this gets more complex. For example if we need to call functions like BLI_str_cursor_step_next_utf8, which assumes that str_len is the actual end of the string. Pull Request: https://projects.blender.org/blender/blender/pulls/121966
This commit is contained in:
committed by
Harley Acheson
parent
99505b58e9
commit
24873963a6
@@ -3114,8 +3114,9 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, con
|
||||
}
|
||||
/* mouse inside the widget, mouse coords mapped in widget space */
|
||||
else {
|
||||
but->pos = but->ofs + BLF_str_offset_from_cursor_position(
|
||||
fstyle.uifont_id, str + but->ofs, INT_MAX, int(x - startx));
|
||||
but->pos = but->ofs +
|
||||
BLF_str_offset_from_cursor_position(
|
||||
fstyle.uifont_id, str + but->ofs, strlen(str + but->ofs), int(x - startx));
|
||||
}
|
||||
|
||||
ui_but_text_password_hide(password_str, but, true);
|
||||
|
||||
Reference in New Issue
Block a user