[FFmpeg-devel] [PATCH] Manage the case when the avctx provided to avcodec_close() is NULL.

avcoder ffmpeg
Sun Dec 5 02:27:39 CET 2010


if movie->codec_ctx is NULL, there must be something went wrong. the caller
should check why it is NULL

avcodec_close() is not good place to hide the wrong.

On Sun, Dec 5, 2010 at 8:54 AM, Stefano Sabatini <
stefano.sabatini-lala at poste.it> wrote:

> On date Sunday 2010-12-05 01:17:16 +0100, Michael Niedermayer encoded:
> > On Sat, Dec 04, 2010 at 07:38:47PM +0100, Stefano Sabatini wrote:
> > > ---
> > >  libavcodec/utils.c |    2 ++
> > >  1 files changed, 2 insertions(+), 0 deletions(-)
> >
> > when is it NULL?
>
> static av_cold void uninit(AVFilterContext *ctx)
> {
>    MovieContext *movie = ctx->priv;
>
>    if (movie->codec_ctx)
>        avcodec_close(movie->codec_ctx);
>    if (movie->format_ctx)
>        av_close_input_file(movie->format_ctx);
>    av_freep(&movie->frame);
>    if (movie->picref)
>        avfilter_unref_buffer(movie->picref);
> }
>
> with the patch you don't have to check for movie->codec_ctx, same for
> the the other patches (it was your idea to add these NULL checks), but
> I can happily live with those additional checks...
>

-- 
-----------------------------------------------------------------------------------------
My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2



More information about the ffmpeg-devel mailing list