[FFmpeg-devel] [RFC] Possible memleak in mpegts demuxer on some malformed mpegts files with too large pes packets

Lars Hammarstrand lars.hammarstrand at gmail.com
Tue Apr 16 14:12:35 CEST 2013


Could this still be an issue or has it been corrected elsewhere?


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 */
--


More information about the ffmpeg-devel mailing list