InputText: fixed ImGuiInputTextCallbackData::InsertChars() mistakenly over growing internal buffer. (#9603, #7925)

Note that the 32-256 ranges may seem misleading because ImVector<> handle its growth policy but it is also the size we request to underlying user impl hence the clamps.
This commit is contained in:
ocornut 2026-10-30 17:32:06 +01:00
parent a13badd73e
commit 1023d3ddaa

View File

@ -4471,7 +4471,7 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons
if (new_text_len + BufTextLen + 1 > obj->TextA.Size && is_resizable && !is_readonly)
{
IM_ASSERT(Buf == obj->TextA.Data);
int new_buf_size = BufTextLen + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1;
int new_buf_size = BufTextLen + ImClamp(new_text_len, 32, ImMax(256, new_text_len)) + 1;
obj->TextA.resize(new_buf_size + 1);
obj->TextSrc = obj->TextA.Data;
Buf = obj->TextA.Data;