[FFmpeg-devel] [PATCH 2/2] avcodec: make avcodec_close() more tolerant.

Michael Niedermayer michaelni at gmx.at
Wed Sep 4 04:11:38 CEST 2013


On Tue, Sep 03, 2013 at 10:32:49PM +0200, Clément Bœsch wrote:
> See previous commit.
> ---
>  doc/APIchanges       | 3 +++
>  libavcodec/utils.c   | 5 +++++
>  libavcodec/version.h | 2 +-
>  3 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 12b9af4..45965e9 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2012-10-22
>  
>  API changes, most recent first:
>  
> +2013-xx-xx - xxxxxxx - lavc 55.31.101 - avcodec.h
> +  avcodec_close() argument can be NULL.
> +
>  2013-xx-xx - xxxxxxx - lavf 55.16.101 - avformat.h
>    avformat_close_input() argument can be NULL and point on NULL.
>  
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 4e510e6..2be0eb5 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -2402,6 +2402,11 @@ av_cold int avcodec_close(AVCodecContext *avctx)
>      if (ret < 0)
>          return ret;
>  
> +    if (!avctx) {
> +        ff_unlock_avcodec();
> +        return 0;
> +    }

probably makes more sense to check before the lock call
otherwise should be ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130904/c7f44421/attachment.asc>


More information about the ffmpeg-devel mailing list