fix [#27568] Segmentation fault in Sequencer when adding an effect strip with python
authorCampbell Barton <ideasman42@gmail.com>
Sat, 4 Jun 2011 10:39:04 +0000 (10:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 4 Jun 2011 10:39:04 +0000 (10:39 +0000)
disallow negative length effect strips.

source/blender/blenkernel/intern/seqeffects.c
source/blender/blenkernel/intern/sequencer.c

index d2f05a8ca530a78cd6fe94d45dae8708d379b94e..c19a74deff6244127ab863a9c3edca8d93284de6 100644 (file)
@@ -3021,10 +3021,15 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
        /* if not already done, load / initialize data */
        get_sequence_effect(seq);
 
-       if (!(force || seq->len != v->length || !v->frameMap)) {
+       if (    (force == FALSE) &&
+                       (seq->len == v->length) &&
+                       (v->frameMap != NULL)
+       ) {
                return;
        }
-       if (!seq->seq1) { /* make coverity happy and check for (CID 598)
+       if (    (seq->seq1 == NULL) ||
+               (seq->len < 1)
+       ) { /* make coverity happy and check for (CID 598)
                                                 input strip ... */
                return;
        }
index 009665f3a1fddb22f31e4aa96967887aaf2e510f..b94782f9a25c0c78b4cffe2447d02e4bef3e9bf2 100644 (file)
@@ -587,8 +587,17 @@ void calc_sequence(Scene *scene, Sequence *seq)
                if (seq->seq1) {
                        seq->start= seq->startdisp= MAX3(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
                        seq->enddisp= MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
+                       /* we cant help if strips don't overlap, it wont give useful results.
+                        * but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
+                       if(seq->enddisp < seq->startdisp) {
+                               /* simple start/end swap */
+                               seq->start= seq->enddisp;
+                               seq->enddisp = seq->startdisp;
+                               seq->startdisp= seq->start;
+                       }
                        seq->len= seq->enddisp - seq->startdisp;
-               } else {
+               }
+               else {
                        calc_sequence_disp(scene, seq);
                }