Fix #147710: Crash binding Surface Deform modifier to faceless mesh
- Add an explicit check with a better error message than "Out of memory" - Initialize SDefVert so the later null checks don't try to free uninitialized data. Pull Request: https://projects.blender.org/blender/blender/pulls/147723
This commit is contained in:
@@ -1183,6 +1183,11 @@ static bool surfacedeformBind(Object *ob,
|
||||
uint tedges_num = target->edges_num;
|
||||
int adj_result;
|
||||
|
||||
if (target->faces_num == 0) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Target has no faces");
|
||||
return false;
|
||||
}
|
||||
|
||||
SDefAdjacencyArray *vert_edges = MEM_calloc_arrayN<SDefAdjacencyArray>(target_verts_num,
|
||||
"SDefVertEdgeMap");
|
||||
if (vert_edges == nullptr) {
|
||||
@@ -1206,7 +1211,7 @@ static bool surfacedeformBind(Object *ob,
|
||||
return false;
|
||||
}
|
||||
|
||||
smd_orig->verts = MEM_malloc_arrayN<SDefVert>(size_t(verts_num), "SDefBindVerts");
|
||||
smd_orig->verts = MEM_calloc_arrayN<SDefVert>(size_t(verts_num), "SDefBindVerts");
|
||||
if (smd_orig->verts == nullptr) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
|
||||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
|
||||
Reference in New Issue
Block a user