From 245133e48fca53a5c683bd54bc97753ecf644ffd Mon Sep 17 00:00:00 2001 From: Anton Klymenko Date: Wed, 15 Oct 2025 15:18:28 +0100 Subject: [PATCH] Fix TextInput selection render accessing offset array out of bounds --- imgui_widgets.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 9ebafa85b..36d1a38fa 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5485,7 +5485,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ const char* text_selected_begin = buf_display + ImMin(state->Stb->select_start, state->Stb->select_end); const char* text_selected_end = buf_display + ImMax(state->Stb->select_start, state->Stb->select_end); - for (int line_n = line_visible_n0; line_n < line_visible_n1; line_n++) + int line_n_max = ImMin(line_visible_n1, line_index->Offsets.Size); // We may not have offsets for all the lines if the text was scrolled this frame + for (int line_n = line_visible_n0; line_n < line_n_max; line_n++) { const char* p = line_index->get_line_begin(buf_display, line_n); const char* p_eol = line_index->get_line_end(buf_display, line_n);