diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index def674c2c..42b36e269 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -89,6 +89,8 @@ Other Changes: - Misc: fixed building with IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION. (#8794) - Misc: removed more redundant inline static linkage from imgui_internal.h to facilitate using in C++ modules. (#8813, #8682, #8358) [@stripe2933] +- Misc: ImVector: skip memcpy in operator= if `Data` isn't initialized in order + to play nice with -fsanitize=undefined. (#8874) [@i25e] - CI: Added SDL3 builds to MacOS and Windows. (#8819, #8778) [@scribam] - CI: Updated Windows CI to use a more recent SDL2. (#8819, #8778) [@scribam] - Examples: SDL3+Metal: added SDL3+Metal example. (#8827, #8825) [@shi-yan] diff --git a/imgui.h b/imgui.h index e490658f1..3112184fc 100644 --- a/imgui.h +++ b/imgui.h @@ -2181,7 +2181,7 @@ struct ImVector // Constructors, destructor inline ImVector() { Size = Capacity = 0; Data = NULL; } inline ImVector(const ImVector& src) { Size = Capacity = 0; Data = NULL; operator=(src); } - inline ImVector& operator=(const ImVector& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; } + inline ImVector& operator=(const ImVector& src) { clear(); resize(src.Size); if (Data && src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; } inline ~ImVector() { if (Data) IM_FREE(Data); } // Important: does not destruct anything inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } // Important: does not destruct anything