From 7ceb6ffe57e1078498315807fbd551c925fc93d5 Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Sun, 26 Jul 2020 14:58:44 +0200 Subject: Fix T74958: Infinite loop on using strip as modifier mask Add recursion check before assigning strip as a mask for modifier. Same check is used for recursion check when reassigning effect input, so it should not be possible to create recursion at all. --- source/blender/makesrna/intern/rna_sequencer.c | 64 +++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'source/blender/makesrna/intern/rna_sequencer.c') diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 6589ae4b8da..d360e37588c 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -862,6 +862,43 @@ static int rna_Sequence_input_count_get(PointerRNA *ptr) return BKE_sequence_effect_get_num_inputs(seq->type); } +static void rna_Sequence_input_set(PointerRNA *ptr, + PointerRNA ptr_value, + struct ReportList *reports, + int input_num) +{ + + Sequence *seq = ptr->data; + Sequence *input = ptr_value.data; + + if (BKE_sequencer_render_loop_check(input, seq)) { + BKE_report(reports, RPT_ERROR, "Cannot reassign inputs: recursion detected."); + return; + } + + switch (input_num) { + case 1: + seq->seq1 = input; + break; + case 2: + seq->seq2 = input; + break; + } +} + +static void rna_Sequence_input_1_set(PointerRNA *ptr, + PointerRNA ptr_value, + struct ReportList *reports) +{ + rna_Sequence_input_set(ptr, ptr_value, reports, 1); +} + +static void rna_Sequence_input_2_set(PointerRNA *ptr, + PointerRNA ptr_value, + struct ReportList *reports) +{ + rna_Sequence_input_set(ptr, ptr_value, reports, 2); +} # if 0 static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value) { @@ -1272,6 +1309,24 @@ static void rna_Sequence_modifier_clear(Sequence *seq, bContext *C) WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); } +static void rna_SequenceModifier_strip_set(PointerRNA *ptr, + PointerRNA value, + struct ReportList *reports) +{ + SequenceModifierData *smd = ptr->data; + Scene *scene = (Scene *)ptr->owner_id; + Editing *ed = BKE_sequencer_editing_get(scene, false); + Sequence *seq = sequence_get_by_modifier(ed, smd); + Sequence *target = (Sequence *)value.data; + + if (target != NULL && BKE_sequencer_render_loop_check(target, seq)) { + BKE_report(reports, RPT_ERROR, "Recursion detected, can not use this strip"); + return; + } + + smd->mask_sequence = target; +} + static float rna_Sequence_fps_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->owner_id; @@ -2193,6 +2248,7 @@ static void rna_def_effect_inputs(StructRNA *srna, int count) prop = RNA_def_property(srna, "input_1", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "seq1"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Sequence_input_1_set", NULL, NULL); RNA_def_property_ui_text(prop, "Input 1", "First input for the effect strip"); } @@ -2200,6 +2256,7 @@ static void rna_def_effect_inputs(StructRNA *srna, int count) prop = RNA_def_property(srna, "input_2", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "seq2"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Sequence_input_2_set", NULL, NULL); RNA_def_property_ui_text(prop, "Input 2", "Second input for the effect strip"); } @@ -3053,8 +3110,11 @@ static void rna_def_modifier(BlenderRNA *brna) prop = RNA_def_property(srna, "input_mask_strip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mask_sequence"); - RNA_def_property_pointer_funcs( - prop, NULL, NULL, NULL, "rna_SequenceModifier_otherSequence_poll"); + RNA_def_property_pointer_funcs(prop, + NULL, + "rna_SequenceModifier_strip_set", + NULL, + "rna_SequenceModifier_otherSequence_poll"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Mask Strip", "Strip used as mask input for the modifier"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SequenceModifier_update"); -- cgit v1.2.3