[Bf-blender-cvs] [8c932ab43c2] master: Fix T96032: add null check to constraint operators

Henrik Dick noreply at git.blender.org
Mon Feb 28 18:32:57 CET 2022


Commit: 8c932ab43c28d476bd0bf671ef70448f075295ef
Author: Henrik Dick
Date:   Mon Feb 28 18:26:58 2022 +0100
Branches: master
https://developer.blender.org/rB8c932ab43c28d476bd0bf671ef70448f075295ef

Fix T96032: add null check to constraint operators

The constraint operators for delete, apply, copy and copy to selected
were missing null checks and could crash blender when called wrongly
from the python api.

Differential Revision: http://developer.blender.org/D14195

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

M	source/blender/editors/object/object_constraint.c

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

diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index d717271b9cb..3f4ed27a175 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -1443,6 +1443,11 @@ static int constraint_delete_exec(bContext *C, wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Object *ob = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, ob, 0);
+
+  if (con == NULL) {
+    return OPERATOR_CANCELLED;
+  }
+
   ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL);
 
   /* Store name temporarily for report. */
@@ -1510,6 +1515,11 @@ static int constraint_apply_exec(bContext *C, wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Object *ob = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, ob, 0);
+
+  if (con == NULL) {
+    return OPERATOR_CANCELLED;
+  }
+
   bPoseChannel *pchan;
   ListBase *constraints = ED_object_constraint_list_from_constraint(ob, con, &pchan);
 
@@ -1602,6 +1612,11 @@ static int constraint_copy_exec(bContext *C, wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Object *ob = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, ob, 0);
+
+  if (con == NULL) {
+    return OPERATOR_CANCELLED;
+  }
+
   bPoseChannel *pchan;
   ListBase *constraints = ED_object_constraint_list_from_constraint(ob, con, &pchan);
 
@@ -1682,6 +1697,11 @@ static int constraint_copy_to_selected_exec(bContext *C, wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Object *obact = ED_object_active_context(C);
   bConstraint *con = edit_constraint_property_get(C, op, obact, 0);
+
+  if (con == NULL) {
+    return OPERATOR_CANCELLED;
+  }
+
   bPoseChannel *pchan;
   ED_object_constraint_list_from_constraint(obact, con, &pchan);



More information about the Bf-blender-cvs mailing list