[Bf-blender-cvs] [b7b5c23b80b] master: Fix memory leak in VSE transform code

Richard Antalik noreply at git.blender.org
Thu Jul 1 22:15:36 CEST 2021


Commit: b7b5c23b80b57b4b2d939e679ec6fc15aa8b8315
Author: Richard Antalik
Date:   Thu Jul 1 22:14:29 2021 +0200
Branches: master
https://developer.blender.org/rBb7b5c23b80b57b4b2d939e679ec6fc15aa8b8315

Fix memory leak in VSE transform code

SeqCollection wasn't freed.

It wasn't easy to find culprit so added argument to
SEQ_collection_create() to pass function name.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11746

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

M	source/blender/editors/transform/transform_convert_sequencer.c
M	source/blender/editors/transform/transform_snap_sequencer.c
M	source/blender/sequencer/SEQ_iterator.h
M	source/blender/sequencer/intern/iterator.c
M	source/blender/sequencer/intern/render.c
M	source/blender/sequencer/intern/strip_edit.c

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

diff --git a/source/blender/editors/transform/transform_convert_sequencer.c b/source/blender/editors/transform/transform_convert_sequencer.c
index 51914004e70..a6f5aba5a1d 100644
--- a/source/blender/editors/transform/transform_convert_sequencer.c
+++ b/source/blender/editors/transform/transform_convert_sequencer.c
@@ -281,7 +281,7 @@ static bool seq_transform_check_overlap(SeqCollection *transformed_strips)
 
 static SeqCollection *extract_standalone_strips(SeqCollection *transformed_strips)
 {
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   Sequence *seq;
   SEQ_ITERATOR_FOREACH (seq, transformed_strips) {
     if ((seq->type & SEQ_TYPE_EFFECT) == 0 || seq->seq1 == NULL) {
@@ -302,7 +302,7 @@ static SeqCollection *query_right_side_strips(ListBase *seqbase, SeqCollection *
     }
   }
 
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
     if ((seq->flag & SELECT) == 0 && seq->startdisp >= minframe) {
       SEQ_collection_append_strip(seq, collection);
@@ -407,7 +407,7 @@ static void seq_transform_handle_overlap(TransInfo *t, SeqCollection *transforme
 
 static SeqCollection *seq_transform_collection_from_transdata(TransDataContainer *tc)
 {
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   TransData *td = tc->data;
   for (int a = 0; a < tc->data_len; a++, td++) {
     Sequence *seq = ((TransDataSeq *)td->extra)->seq;
@@ -428,6 +428,7 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
 
   if (t->state == TRANS_CANCEL) {
     seq_transform_cancel(t, transformed_strips);
+    SEQ_collection_free(transformed_strips);
     free_transform_custom_data(custom_data);
     return;
   }
diff --git a/source/blender/editors/transform/transform_snap_sequencer.c b/source/blender/editors/transform/transform_snap_sequencer.c
index 91bebc9c59d..d9395e5e960 100644
--- a/source/blender/editors/transform/transform_snap_sequencer.c
+++ b/source/blender/editors/transform/transform_snap_sequencer.c
@@ -108,7 +108,7 @@ static SeqCollection *query_snap_targets(const TransInfo *t)
 {
   const ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(t->scene, false));
   const short snap_flag = SEQ_tool_settings_snap_flag_get(t->scene);
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
     if ((seq->flag & SELECT)) {
       continue; /* Selected are being transformed. */
diff --git a/source/blender/sequencer/SEQ_iterator.h b/source/blender/sequencer/SEQ_iterator.h
index eab2277bbe3..aa2e182e1c0 100644
--- a/source/blender/sequencer/SEQ_iterator.h
+++ b/source/blender/sequencer/SEQ_iterator.h
@@ -70,7 +70,7 @@ bool SEQ_iterator_ensure(SeqCollection *collection,
                          struct Sequence **r_seq);
 struct Sequence *SEQ_iterator_yield(SeqIterator *iterator);
 
-SeqCollection *SEQ_collection_create(void);
+SeqCollection *SEQ_collection_create(const char *name);
 uint SEQ_collection_len(const SeqCollection *collection);
 bool SEQ_collection_append_strip(struct Sequence *seq, SeqCollection *data);
 bool SEQ_collection_remove_strip(struct Sequence *seq, SeqCollection *data);
diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c
index 0754d9b38ed..20a2ee3b183 100644
--- a/source/blender/sequencer/intern/iterator.c
+++ b/source/blender/sequencer/intern/iterator.c
@@ -106,9 +106,9 @@ void SEQ_collection_free(SeqCollection *collection)
  *
  * \return empty strip collection.
  */
-SeqCollection *SEQ_collection_create(void)
+SeqCollection *SEQ_collection_create(const char *name)
 {
-  SeqCollection *collection = MEM_callocN(sizeof(SeqCollection), "SeqCollection");
+  SeqCollection *collection = MEM_callocN(sizeof(SeqCollection), name);
   collection->set = BLI_gset_new(
       BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SeqCollection GSet");
   return collection;
@@ -136,7 +136,7 @@ SeqCollection *SEQ_query_by_reference(Sequence *seq_reference,
                                                           ListBase *seqbase,
                                                           SeqCollection *collection))
 {
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   seq_query_func(seq_reference, seqbase, collection);
   return collection;
 }
@@ -223,7 +223,7 @@ void SEQ_collection_expand(ListBase *seqbase,
  */
 SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase)
 {
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
     if (seq->type == SEQ_TYPE_META) {
       SEQ_collection_merge(collection, SEQ_query_all_strips_recursive(&seq->seqbase));
@@ -241,7 +241,7 @@ SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase)
  */
 SeqCollection *SEQ_query_all_strips(ListBase *seqbase)
 {
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
     SEQ_collection_append_strip(seq, collection);
   }
@@ -256,7 +256,7 @@ SeqCollection *SEQ_query_all_strips(ListBase *seqbase)
  */
 SeqCollection *SEQ_query_selected_strips(ListBase *seqbase)
 {
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
     if ((seq->flag & SELECT) == 0) {
       continue;
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 7360d525ce3..2f6f0180835 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -308,7 +308,7 @@ static bool must_render_strip(const Sequence *seq, SeqCollection *strips_at_time
 
 static SeqCollection *query_strips_at_frame(ListBase *seqbase, const int timeline_frame)
 {
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
 
   LISTBASE_FOREACH (Sequence *, seq, seqbase) {
     if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c
index 3e6eb74fcb3..b9278b9f971 100644
--- a/source/blender/sequencer/intern/strip_edit.c
+++ b/source/blender/sequencer/intern/strip_edit.c
@@ -255,7 +255,7 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene,
     return false;
   }
 
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   SEQ_collection_append_strip(src_seq, collection);
   SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);
 
@@ -396,7 +396,7 @@ Sequence *SEQ_edit_strip_split(Main *bmain,
     return NULL;
   }
 
-  SeqCollection *collection = SEQ_collection_create();
+  SeqCollection *collection = SEQ_collection_create(__func__);
   SEQ_collection_append_strip(seq, collection);
   SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);



More information about the Bf-blender-cvs mailing list