[FFmpeg-devel] [PATCH]Avoid a null pointer dereference on clean-up in the ac3 encoder

Carl Eugen Hoyos cehoyos at ag.or.at
Sat Jun 29 17:43:10 CEST 2013


Hi!

Attached patch fixes a null pointer dereference that I found while testing 
ticket #2730 (I don't think this is the reported problem, I see "Cannot 
allocate memory." from ff_ac3_float_mdct_init() before the crash).

Please review, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index a0b810e..37c496c 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -2017,6 +2017,7 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
     AC3EncodeContext *s = avctx->priv_data;
 
     av_freep(&s->windowed_samples);
+    if (s->planar_samples)
     for (ch = 0; ch < s->channels; ch++)
         av_freep(&s->planar_samples[ch]);
     av_freep(&s->planar_samples);


More information about the ffmpeg-devel mailing list