safety NULL check for r51327, don't assume ED_object_modifier_add() succeeds.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 15 Oct 2012 03:56:01 +0000 (03:56 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 15 Oct 2012 03:56:01 +0000 (03:56 +0000)
source/blender/editors/object/object_relations.c

index b7efe9189d8c6bc2f7829ad8e53fd86ebe782e73..447ba29e20316ef73dc739c4c13186a09a21c611 100644 (file)
@@ -679,21 +679,27 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object
                                        
                                        switch (partype) {
                                                case PAR_CURVE: /* curve deform */
-                                                       if (modifiers_isDeformedByCurve(ob) != par) {
+                                                       if ( modifiers_isDeformedByCurve(ob) != par) {
                                                                md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve);
-                                                               ((CurveModifierData *)md)->object = par;
+                                                               if (md) {
+                                                                       ((CurveModifierData *)md)->object = par;
+                                                               }
                                                        }
                                                        break;
                                                case PAR_LATTICE: /* lattice deform */
                                                        if (modifiers_isDeformedByLattice(ob) != par) {
                                                                md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice);
-                                                               ((LatticeModifierData *)md)->object = par;
+                                                               if (md) {
+                                                                       ((LatticeModifierData *)md)->object = par;
+                                                               }
                                                        }
                                                        break;
                                                default: /* armature deform */
                                                        if (modifiers_isDeformedByArmature(ob) != par) {
                                                                md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature);
-                                                               ((ArmatureModifierData *)md)->object = par;
+                                                               if (md) {
+                                                                       ((ArmatureModifierData *)md)->object = par;
+                                                               }
                                                        }
                                                        break;
                                        }