[Bf-blender-cvs] [dfefafa814d] master: Fix uninitialized memory use loading movie sequence strips

Campbell Barton noreply at git.blender.org
Sun Mar 21 04:16:25 CET 2021


Commit: dfefafa814dd8daf1fe0e49f48e5ddbf6435bbfe
Author: Campbell Barton
Date:   Sun Mar 21 14:08:32 2021 +1100
Branches: master
https://developer.blender.org/rBdfefafa814dd8daf1fe0e49f48e5ddbf6435bbfe

Fix uninitialized memory use loading movie sequence strips

When the movie wasn't found, uninitialized values would be used for
the original width/height.

Also use int instead of float as the image size is stored as an int.

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

M	source/blender/makesdna/DNA_sequence_types.h
M	source/blender/sequencer/intern/strip_add.c

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

diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h
index 4211c913a0c..fa11a7dfd13 100644
--- a/source/blender/makesdna/DNA_sequence_types.h
+++ b/source/blender/makesdna/DNA_sequence_types.h
@@ -55,6 +55,7 @@ typedef struct StripAnim {
 
 typedef struct StripElem {
   char name[256];
+  /** Ignore when zeroed. */
   int orig_width, orig_height;
 } StripElem;
 
diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c
index 932b358cb37..33dd74cb527 100644
--- a/source/blender/sequencer/intern/strip_add.c
+++ b/source/blender/sequencer/intern/strip_add.c
@@ -468,8 +468,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
   const int totfiles = seq_num_files(scene, load_data->views_format, load_data->use_multiview);
   struct anim **anim_arr = MEM_callocN(sizeof(struct anim *) * totfiles, "Video files");
   int i;
-  float width;
-  float height;
+  int orig_width = 0;
+  int orig_height = 0;
 
   if (load_data->use_multiview && (load_data->views_format == R_IMF_VIEWS_INDIVIDUAL)) {
     char prefix[FILE_MAX];
@@ -540,9 +540,10 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
     }
 
     /* Set initial scale based on load_data->fit_method. */
-    width = IMB_anim_get_image_width(anim_arr[0]);
-    height = IMB_anim_get_image_height(anim_arr[0]);
-    SEQ_set_scale_to_fit(seq, width, height, scene->r.xsch, scene->r.ysch, load_data->fit_method);
+    orig_width = IMB_anim_get_image_width(anim_arr[0]);
+    orig_height = IMB_anim_get_image_height(anim_arr[0]);
+    SEQ_set_scale_to_fit(
+        seq, orig_width, orig_height, scene->r.xsch, scene->r.ysch, load_data->fit_method);
   }
 
   seq->len = MAX2(1, seq->len);
@@ -554,8 +555,8 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
   /* We only need 1 element for MOVIE strips. */
   StripElem *se;
   strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem");
-  strip->stripdata->orig_width = width;
-  strip->stripdata->orig_height = height;
+  strip->stripdata->orig_width = orig_width;
+  strip->stripdata->orig_height = orig_height;
   BLI_split_dirfile(load_data->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name));
 
   seq_add_set_name(seq, load_data);



More information about the Bf-blender-cvs mailing list