From dfefafa814dd8daf1fe0e49f48e5ddbf6435bbfe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Mar 2021 14:08:32 +1100 Subject: 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. --- source/blender/sequencer/intern/strip_add.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source/blender/sequencer') 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); -- cgit v1.2.3