From e4b876ec601d821028d71d435587a0f31a3ad2fe Mon Sep 17 00:00:00 2001 From: douglaspotesta Date: Sat, 19 Sep 2026 16:38:43 -0400 Subject: [PATCH] Fix string field inputs using INT_MAX capacity --- imgui_widgets.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 1f60853b6..e84ff0534 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4925,7 +4925,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ IM_ASSERT(new_len + 1 <= buf_size && "Is your input buffer properly zero-terminated?"); state->WantReloadUserBuf = false; InputTextReconcileUndoState(state, state->TextA.Data, state->TextLen, buf, new_len); - state->TextA.resize(buf_size + 1); // we use +1 to make sure that .Data is always pointing to at least an empty string. + state->TextA.resize(buf_size < INT_MAX ? buf_size + 1 : buf_size); // we use +1 to make sure that .Data is always pointing to at least an empty string. state->TextLen = new_len; memcpy(state->TextA.Data, buf, state->TextLen + 1); state->Stb->select_start = state->ReloadSelectionStart; @@ -4963,7 +4963,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ state->EditedBefore = false; if (!is_readonly) { - state->TextA.resize(buf_size + 1); // we use +1 to make sure that .Data is always pointing to at least an empty string. + state->TextA.resize(buf_size < INT_MAX ? buf_size + 1 : buf_size); // we use +1 to make sure that .Data is always pointing to at least an empty string. memcpy(state->TextA.Data, buf, state->TextLen + 1); }