From 5a43cd3b64664d891888a93bc120c6650b73ccd5 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 21 Mar 2012 13:54:13 -0700 Subject: [PATCH] Use avformat_free_context to free a format context that failed to open --- examples/alffmpeg.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/alffmpeg.c b/examples/alffmpeg.c index ed4c46e0..903d85ee 100644 --- a/examples/alffmpeg.c +++ b/examples/alffmpeg.c @@ -205,8 +205,12 @@ FilePtr openAVData(const char *name, char *buffer, size_t buffer_len) { if(avformat_find_stream_info(file->FmtCtx, NULL) >= 0) return file; + av_close_input_file(file->FmtCtx); + file->FmtCtx = NULL; } - av_close_input_file(file->FmtCtx); + if(file->FmtCtx) + avformat_free_context(file->FmtCtx); + file->FmtCtx = NULL; } free(file); @@ -236,8 +240,12 @@ FilePtr openAVCustom(const char *name, void *user_data, { if(avformat_find_stream_info(file->FmtCtx, NULL) >= 0) return file; + av_close_input_file(file->FmtCtx); + file->FmtCtx = NULL; } - av_close_input_file(file->FmtCtx); + if(file->FmtCtx) + avformat_free_context(file->FmtCtx); + file->FmtCtx = NULL; } free(file); -- 2.11.4.GIT