From b83c9a2505338cdf021dd499c26686e82bcbc066 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Fri, 26 Nov 2010 20:56:48 +0000 Subject: [PATCH 15/24] fixed: memleak in mpegts demuxer on some malformed (??) mpegts files with too large pes packets at-visions sample file brokenStream.mpg --- libavformat/mpegts.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index ba2f163..c374cb9 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -664,6 +664,10 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, static void new_pes_packet(PESContext *pes, AVPacket *pkt) { + if(pkt->data) { + av_log(pes->stream, AV_LOG_ERROR, "ignoring previously allocated packet on stream %d\n", pkt->stream_index); + av_free_packet(pkt); + } av_init_packet(pkt); pkt->destruct = av_destruct_packet; @@ -2117,6 +2121,8 @@ static int mpegts_read_packet(AVFormatContext *s, int ret, i; ts->pkt = pkt; + ts->pkt->data = NULL; + ret = handle_packets(ts, 0); if (ret < 0) { /* flush pes data left */ -- 1.7.9.4