diff options
author | Luca Rood <dev@lucarood.com> | 2017-04-13 16:39:16 +0300 |
---|---|---|
committer | Luca Rood <dev@lucarood.com> | 2017-04-13 16:40:50 +0300 |
commit | 0a032ce83be78a02b92ffe4544fac46d6d3c8f03 (patch) | |
tree | 83d4f76f50fcb6bb3b7522a043cf6da997220540 /source/blender/modifiers/intern/MOD_surfacedeform.c | |
parent | 360cf8393a22f7beec81340ddd0aaa3bfd22275c (diff) |
Fix Surface Deform crash with missing or freed DM
Diffstat (limited to 'source/blender/modifiers/intern/MOD_surfacedeform.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index 776cf02754e..da9b926d1f4 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -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, |