[Bf-blender-cvs] [17e0634902b] blender-v3.1-release: Fix T95985: crash when assigning a name for an output attribute

Jacques Lucke noreply at git.blender.org
Thu Feb 24 12:44:16 CET 2022


Commit: 17e0634902b7fc8987918e02bc2d4e2090c32e02
Author: Jacques Lucke
Date:   Thu Feb 24 12:44:02 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB17e0634902b7fc8987918e02bc2d4e2090c32e02

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

===================================================================

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



More information about the Bf-blender-cvs mailing list