[FFmpeg-devel] [PATCH] Segfault occurs if encoder initialization fails

Michael Niedermayer michaelni
Tue Apr 6 02:48:54 CEST 2010


On Mon, Apr 05, 2010 at 06:08:23PM -0500, Craig Thomasson wrote:
> Hi,
> 
> This patch fixes an issue where ffmpeg segfaults if the encoder fails to
> initialize.  avcodec_close() needs to check if avctx->codec is non-null
> before dereferencing it, as it is set to null prior to this call when
> encoder init fails.
> 
> --------------------------------
> diff -u ffmpeg/libavcodec/utils.c working/libavcodec/utils.c
> --- ffmpeg/libavcodec/utils.c	2010-04-05 17:26:55.000000000 -0500
> +++ working/libavcodec/utils.c	2010-04-05 17:36:00.000000000 -0500
> @@ -710,7 +710,7 @@
>          avctx->codec->close(avctx);
>      avcodec_default_free_buffers(avctx);
>      av_freep(&avctx->priv_data);
> -    if(avctx->codec->encode)
> +    if(avctx->codec && avctx->codec->encode)
>          av_freep(&avctx->extradata);

probably ok

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100406/f103a810/attachment.pgp>



More information about the ffmpeg-devel mailing list