Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Dick <hen-di@web.de>2022-02-28 20:26:58 +0300
committerHenrik Dick <hen-di@web.de>2022-02-28 20:26:58 +0300
commit8c932ab43c28d476bd0bf671ef70448f075295ef (patch)
tree0fafb9a8237c6df7c1db9aa9a526d56cae71b0fa /source/blender/editors/object/object_constraint.c
parent245722866d6977c8b440e0f468ebf6528d3970e1 (diff)
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
Diffstat (limited to 'source/blender/editors/object/object_constraint.c')
-rw-r--r--source/blender/editors/object/object_constraint.c20
1 files changed, 20 insertions, 0 deletions
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);