Fix Surface Deform crash with missing or freed DM
This commit is contained in:
@@ -1120,6 +1120,11 @@ static void surfacedeformModifier_do(ModifierData *md, float (*vertexCos)[3], un
|
||||
tdm = smd->target->derivedFinal;
|
||||
}
|
||||
|
||||
if (!tdm) {
|
||||
modifier_setError(md, "No valid target mesh");
|
||||
return;
|
||||
}
|
||||
|
||||
tnumverts = tdm->getNumVerts(tdm);
|
||||
tnumpoly = tdm->getNumPolys(tdm);
|
||||
|
||||
@@ -1139,12 +1144,10 @@ static void surfacedeformModifier_do(ModifierData *md, float (*vertexCos)[3], un
|
||||
/* Poly count checks */
|
||||
if (smd->numverts != numverts) {
|
||||
modifier_setError(md, "Verts changed from %u to %u", smd->numverts, numverts);
|
||||
tdm->release(tdm);
|
||||
return;
|
||||
}
|
||||
else if (smd->numpoly != tnumpoly) {
|
||||
modifier_setError(md, "Target polygons changed from %u to %u", smd->numpoly, tnumpoly);
|
||||
tdm->release(tdm);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1170,8 +1173,6 @@ static void surfacedeformModifier_do(ModifierData *md, float (*vertexCos)[3], un
|
||||
|
||||
MEM_freeN(data.targetCos);
|
||||
}
|
||||
|
||||
tdm->release(tdm);
|
||||
}
|
||||
|
||||
static void deformVerts(ModifierData *md, Object *ob,
|
||||
|
||||
Reference in New Issue
Block a user