From 9c71ec38f0f79278aefcf785f436a09c97bc3689 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 12 Jul 2016 11:19:38 +0200 Subject: [PATCH] ImVector: reserve() tweak to avoid undefined behavior warning (#731) --- imgui.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.h b/imgui.h index 805aa996..dffb5060 100644 --- a/imgui.h +++ b/imgui.h @@ -885,7 +885,8 @@ public: { if (new_capacity <= Capacity) return; T* new_data = (value_type*)ImGui::MemAlloc((size_t)new_capacity * sizeof(value_type)); - memcpy(new_data, Data, (size_t)Size * sizeof(value_type)); + if (Data) + memcpy(new_data, Data, (size_t)Size * sizeof(value_type)); ImGui::MemFree(Data); Data = new_data; Capacity = new_capacity;