diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-03-21 06:08:32 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-03-21 06:12:58 +0300 |
commit | dfefafa814dd8daf1fe0e49f48e5ddbf6435bbfe (patch) | |
tree | 7f8a885ec55fcf22ce5ba6ab3e67dd604dd7a437 /source | |
parent | fce3e6646e859d769b19b4253c753dca6c4849af (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesdna/DNA_sequence_types.h | 1 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_add.c | 15 |
2 files changed, 9 insertions, 7 deletions
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); |