From 17e0634902b7fc8987918e02bc2d4e2090c32e02 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 24 Feb 2022 12:44:02 +0100 Subject: Fix T95985: crash when assigning a name for an output attribute This was a double free error which happened because `BM_mesh_bm_from_me` was taking ownership of arrays that were still owned by the Mesh. Note that this only happens when the mesh is empty but some custom data layers still have a non-null data pointer. While usually the data pointer should be null in this case for performance reasons, other functions should still be able to handle this situation. Differential Revision: https://developer.blender.org/D14181 --- source/blender/bmesh/intern/bmesh_mesh_convert.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/bmesh/intern/bmesh_mesh_convert.cc') diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc index 4635da29d34..ee0e5789169 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc @@ -226,10 +226,10 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar if (!me || !me->totvert) { if (me && is_new) { /* No verts? still copy custom-data layout. */ - CustomData_copy(&me->vdata, &bm->vdata, mask.vmask, CD_ASSIGN, 0); - CustomData_copy(&me->edata, &bm->edata, mask.emask, CD_ASSIGN, 0); - CustomData_copy(&me->ldata, &bm->ldata, mask.lmask, CD_ASSIGN, 0); - CustomData_copy(&me->pdata, &bm->pdata, mask.pmask, CD_ASSIGN, 0); + CustomData_copy(&me->vdata, &bm->vdata, mask.vmask, CD_DEFAULT, 0); + CustomData_copy(&me->edata, &bm->edata, mask.emask, CD_DEFAULT, 0); + CustomData_copy(&me->ldata, &bm->ldata, mask.lmask, CD_DEFAULT, 0); + CustomData_copy(&me->pdata, &bm->pdata, mask.pmask, CD_DEFAULT, 0); CustomData_bmesh_init_pool(&bm->vdata, me->totvert, BM_VERT); CustomData_bmesh_init_pool(&bm->edata, me->totedge, BM_EDGE); -- cgit v1.2.3