[FFmpeg-devel] [PATCH] mpegtsenc: fix free of adts when not using AAC

Chris Kennedy bitbytebit at gmail.com
Wed Oct 12 21:11:01 CEST 2011

There is a free for the adts data in writing the trailer onto mpegts
files, yet it is only allocated when we are using AAC.  I have seen
backtraces that point to this as the issue, although it oddly only
segfaults on a very rare occasion.  

Chris Kennedy
ckennedy at groovy.org
-------------- next part --------------
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 1eb935c..1419af0 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1063,7 +1063,8 @@ static int mpegts_write_end(AVFormatContext *s)
                              ts_st->payload_pts, ts_st->payload_dts,
                              ts_st->payload_flags & AV_PKT_FLAG_KEY);
-        av_freep(&ts_st->adts);
+        if (ts_st->adts)
+            av_freep(&ts_st->adts);

More information about the ffmpeg-devel mailing list