[FFmpeg-devel] [PATCH] Segfault occurs if encoder initialization fails
Craig Thomasson
Craig.Thomasson
Tue Apr 6 01:08:23 CEST 2010
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);
avctx->codec = NULL;
entangled_thread_counter--;
--------------------------------
Craig
More information about the ffmpeg-devel
mailing list