[Bf-blender-cvs] [0a032ce83be] master: Fix Surface Deform crash with missing or freed DM

Luca Rood noreply at git.blender.org
Thu Apr 13 15:42:36 CEST 2017


Commit: 0a032ce83be78a02b92ffe4544fac46d6d3c8f03
Author: Luca Rood
Date:   Thu Apr 13 15:39:16 2017 +0200
Branches: master
https://developer.blender.org/rB0a032ce83be78a02b92ffe4544fac46d6d3c8f03

Fix Surface Deform crash with missing or freed DM

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

M	source/blender/modifiers/intern/MOD_surfacedeform.c

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

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,




More information about the Bf-blender-cvs mailing list