Fix for crash in anim render: The callbacks in bMovieHandle are expected

to exist and accessed without prior NULL checks (with exception of
get_next_frame and get_movie_path). The callbacks are not reliably
initialized however if none of the video formats is enabled (AVI being
the default). Added stub functions now that ensure access to
bMovieHandle callbacks is safe and doesn't crash.
This commit is contained in:
Lukas Tönne 2014-01-07 14:51:59 +01:00
parent 01df756bd1
commit e23bcbbb6d

@ -50,6 +50,17 @@
/* ********************** general blender movie support ***************************** */
static int start_stub(Scene *UNUSED(scene), RenderData *UNUSED(rd), int UNUSED(rectx), int UNUSED(recty),
ReportList *UNUSED(reports))
{ return 0; }
static void end_stub(void)
{}
static int append_stub(RenderData *UNUSED(rd), int UNUSED(start_frame), int UNUSED(frame), int *UNUSED(pixels),
int UNUSED(rectx), int UNUSED(recty), ReportList *UNUSED(reports))
{ return 0; }
#ifdef WITH_AVI
# include "AVI_avi.h"
@ -74,13 +85,18 @@ static void filepath_avi(char *string, RenderData *rd);
bMovieHandle *BKE_movie_handle_get(const char imtype)
{
static bMovieHandle mh = {NULL};
/* stub callbacks in case none of the movie formats is supported */
mh.start_movie = start_stub;
mh.append_movie = append_stub;
mh.end_movie = end_stub;
mh.get_next_frame = NULL;
mh.get_movie_path = NULL;
/* set the default handle, as builtin */
#ifdef WITH_AVI
mh.start_movie = start_avi;
mh.append_movie = append_avi;
mh.end_movie = end_avi;
mh.get_next_frame = NULL;
mh.get_movie_path = filepath_avi;
#endif