浏览代码

ImVector: reserve() tweak to avoid undefined behavior warning (#731)

ocornut 9 年之前
父节点
当前提交
9c71ec38f0
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      imgui.h

+ 2 - 1
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;