diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-03-04 12:09:38 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-03-04 12:09:38 +0400 |
commit | dad96000048cbc30e0d21c567668aaa32dece4dd (patch) | |
tree | 53d8c7c14f58dddfce12bf30aed1a4c01cc35c0a /source/blender/modifiers | |
parent | 13290d5a16b3496e1dcec1944563f4124696e034 (diff) |
Fix T38941: Laplacian Deform crashes on OSX
When vgroup was invalid somehow (e.g. empty, as in this case) and bind could not happen, code was dereferencing a NULL pointer...
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r-- | source/blender/modifiers/intern/MOD_laplaciandeform.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index fa56698e1dc..9ed99fc4aed 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -755,27 +755,27 @@ static void LaplacianDeformModifier_do( } } else { - if (lmd->total_verts > 0 && lmd->total_verts == numVerts) { - if (isValidVertexGroup(lmd, ob, dm)) { - filevertexCos = MEM_mallocN(sizeof(float[3]) * numVerts, "TempDeformCoordinates"); - memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * numVerts); - MEM_SAFE_FREE(lmd->vertexco); - lmd->total_verts = 0; - initSystem(lmd, ob, dm, filevertexCos, numVerts); - sys = lmd->cache_system; - MEM_SAFE_FREE(filevertexCos); - laplacianDeformPreview(sys, vertexCos); - } + if (!isValidVertexGroup(lmd, ob, dm)) { + modifier_setError(&lmd->modifier, "Vertex group '%s' is not valid", lmd->anchor_grp_name); + lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND; + } + else if (lmd->total_verts > 0 && lmd->total_verts == numVerts) { + filevertexCos = MEM_mallocN(sizeof(float[3]) * numVerts, "TempDeformCoordinates"); + memcpy(filevertexCos, lmd->vertexco, sizeof(float[3]) * numVerts); + MEM_SAFE_FREE(lmd->vertexco); + lmd->total_verts = 0; + initSystem(lmd, ob, dm, filevertexCos, numVerts); + sys = lmd->cache_system; + MEM_SAFE_FREE(filevertexCos); + laplacianDeformPreview(sys, vertexCos); } else { - if (isValidVertexGroup(lmd, ob, dm)) { - initSystem(lmd, ob, dm, vertexCos, numVerts); - sys = lmd->cache_system; - laplacianDeformPreview(sys, vertexCos); - } + initSystem(lmd, ob, dm, vertexCos, numVerts); + sys = lmd->cache_system; + laplacianDeformPreview(sys, vertexCos); } } - if (sys->is_matrix_computed && !sys->has_solution) { + if (sys && sys->is_matrix_computed && !sys->has_solution) { modifier_setError(&lmd->modifier, "The system did not find a solution"); } } |