Fix T99678: Crash applying non-existent modifiers

Regression in [0] accessed the modifier type before NULL check.

[0]: 78fc5ea1c3
This commit is contained in:
Campbell Barton 2022-07-21 12:52:24 +10:00
parent 9f68369247
commit e75adb979b
Notes: blender-bot 2023-02-14 09:02:40 +01:00
Referenced by issue #100363, Crash after running api command bpy.ops.object.modifier_apply()
Referenced by issue #99678, Regression: Blender crash when trying to apply a none-existing modifier through python script.
Referenced by issue #98661, 3.2: Potential candidates for corrective releases
1 changed files with 2 additions and 1 deletions

View File

@ -1439,7 +1439,6 @@ static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, boo
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
const bool do_report = RNA_boolean_get(op->ptr, "report");
const bool do_single_user = RNA_boolean_get(op->ptr, "single_user");
const bool do_merge_customdata = RNA_boolean_get(op->ptr, "merge_customdata");
@ -1448,6 +1447,8 @@ static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, boo
return OPERATOR_CANCELLED;
}
const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
if (do_single_user && ID_REAL_USERS(ob->data) > 1) {
ED_object_single_obdata_user(bmain, scene, ob);
BKE_main_id_newptr_and_tag_clear(bmain);