Fix invalid array index in armature_deform_verts().
authorNicholas Bishop <nicholasbishop@gmail.com>
Mon, 11 Jun 2012 11:00:58 +0000 (11:00 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Mon, 11 Jun 2012 11:00:58 +0000 (11:00 +0000)
Check that the def_nr is non-negative before using as index.

Fixes bug [#31700] Crash when opening .blend file on 64bit environment

source/blender/blenkernel/intern/armature.c

index 5ad81db1979b6e11edccfe8514fd2f8d0cefe440..9af1d5f52c4a5dea12deb37ef8c178afb89d6d4b 100644 (file)
@@ -986,7 +986,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float
 
                        for (j = dvert->totweight; j != 0; j--, dw++) {
                                const int index = dw->def_nr;
-                               if (index < defbase_tot && (pchan = defnrToPC[index])) {
+                               if (index >= 0 && index < defbase_tot && (pchan = defnrToPC[index])) {
                                        float weight = dw->weight;
                                        Bone *bone = pchan->bone;
                                        pdef_info = pdef_info_array + defnrToPCIndex[index];