[FFmpeg-cvslog] mpegts: Share the cleanup code between the demuxer and lavf-internal parser functions

Martin Storsjö git at videolan.org
Mon Jan 21 13:51:45 CET 2013


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Sun Jan 20 01:59:08 2013 +0200| [a717f9904227d7979473bad40c50eb40af41d01d] | committer: Martin Storsjö

mpegts: Share the cleanup code between the demuxer and lavf-internal parser functions

The lavf-internal parser functions are used when receiving
mpegts over RTP. This fixes memory leaks in this setup.

The normal mpegts demuxer close function was updated in ec7d0d2e in
2004 to fix leaks, but the parsing function used for RTP wasn't
updated and has been leaking ever since.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a717f9904227d7979473bad40c50eb40af41d01d
---

 libavformat/mpegts.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 7c4d447..399b074 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2029,16 +2029,20 @@ static int mpegts_read_packet(AVFormatContext *s,
     return ret;
 }
 
-static int mpegts_read_close(AVFormatContext *s)
+static void mpegts_free(MpegTSContext *ts)
 {
-    MpegTSContext *ts = s->priv_data;
     int i;
 
     clear_programs(ts);
 
     for(i=0;i<NB_PID_MAX;i++)
         if (ts->pids[i]) mpegts_close_filter(ts, ts->pids[i]);
+}
 
+static int mpegts_read_close(AVFormatContext *s)
+{
+    MpegTSContext *ts = s->priv_data;
+    mpegts_free(ts);
     return 0;
 }
 
@@ -2150,10 +2154,7 @@ int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
 
 void ff_mpegts_parse_close(MpegTSContext *ts)
 {
-    int i;
-
-    for(i=0;i<NB_PID_MAX;i++)
-        av_free(ts->pids[i]);
+    mpegts_free(ts);
     av_free(ts);
 }
 



More information about the ffmpeg-cvslog mailing list