From dad96000048cbc30e0d21c567668aaa32dece4dd Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 4 Mar 2014 09:09:38 +0100 Subject: 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... --- .../blender/modifiers/intern/MOD_laplaciandeform.c | 34 +++++++++++----------- 1 file 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"); } } -- cgit v1.2.3