mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
ImVector: skip memcpy in operator= if Data isn't initialized to play nice with -fsanitize=undefined. (#8874)
This commit is contained in:
parent
b6614f6c7c
commit
ea075ed973
2 changed files with 3 additions and 1 deletions
2
imgui.h
2
imgui.h
|
|
@ -2181,7 +2181,7 @@ struct ImVector
|
|||
// Constructors, destructor
|
||||
inline ImVector() { Size = Capacity = 0; Data = NULL; }
|
||||
inline ImVector(const ImVector<T>& src) { Size = Capacity = 0; Data = NULL; operator=(src); }
|
||||
inline ImVector<T>& operator=(const ImVector<T>& src) { clear(); resize(src.Size); if (src.Data) memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; }
|
||||
inline ImVector<T>& operator=(const ImVector<T>& 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue