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
This commit is contained in:
Jacques Lucke 2022-02-24 12:44:02 +01:00
parent e767a2d98b
commit 17e0634902
Notes: blender-bot 2023-02-14 08:33:26 +01:00
Referenced by issue #95985, Geometry Nodes: Crashes when assigning a name for an output attribute
1 changed files with 4 additions and 4 deletions

View File

@ -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);