From 444001bda6adbabf458823b92a9b2a4991457d8d Mon Sep 17 00:00:00 2001 From: d s Date: Tue, 26 Mar 2013 19:36:18 -0700 Subject: [PATCH] Fix avisynth_context_create constructor error handling. Signed-off-by: Michael Niedermayer --- libavformat/avisynth.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index d31031dd15..3119a45204 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -164,8 +164,14 @@ static av_cold int avisynth_context_create(AVFormatContext *s) { return ret; } - if (!avs) - return AVERROR_UNKNOWN; + avs->env = avs_library->avs_create_script_environment(3); + if (avs_library->avs_get_error) { + const char *error = avs_library->avs_get_error(avs->env); + if (error) { + av_log(s, AV_LOG_ERROR, "%s\n", error); + return AVERROR_UNKNOWN; + } + } if (!avs_ctx_list) { avs_ctx_list = avs; @@ -174,16 +180,6 @@ static av_cold int avisynth_context_create(AVFormatContext *s) { avs_ctx_list = avs; } - avs->env = avs_library->avs_create_script_environment(3); - if (avs_library->avs_get_error) { - const char *error = avs_library->avs_get_error(avs->env); - if (error) { - av_log(s, AV_LOG_ERROR, "%s\n", error); - av_free(avs); - return AVERROR_UNKNOWN; - } - } - return 0; }