From eea836135ad5ea980b8131825356e90dfd6a8b13 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sun, 5 Dec 2021 19:03:40 +0100 Subject: [PATCH] InputText: fix buffer modifications in callbacks while using resize callback (#4784) Regressed by 5ac25e7c7 (#4762) --- imgui_widgets.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 0ebb348d..6d8d9ccc 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4510,7 +4510,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ callback(&callback_data); // Read back what user may have modified - IM_ASSERT(callback_data.Buf == callback_buf); // Invalid to modify those fields + callback_buf = is_readonly ? buf : state->TextA.Data; // Pointer may have been invalidated by a resize callback + IM_ASSERT(callback_data.Buf == callback_buf); // Invalid to modify those fields IM_ASSERT(callback_data.BufSize == state->BufCapacityA); IM_ASSERT(callback_data.Flags == flags); const bool buf_dirty = callback_data.BufDirty;