mpegts: Make sure we don't return uninitialized packets
authorMartin Storsjö <martin@martin.st>
Sat, 21 Apr 2012 17:44:24 +0000 (20:44 +0300)
committerMartin Storsjö <martin@martin.st>
Fri, 27 Apr 2012 17:05:37 +0000 (20:05 +0300)
This fixes crashes, where the demuxer could return 0 even
if the returned AVPacket isn't initialized at all. This
could happen if running into EOF or running out of probesize
with non-seekable sources.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/mpegts.c

index c853e72..2222f25 100644 (file)
@@ -2020,6 +2020,7 @@ static int mpegts_read_packet(AVFormatContext *s,
     MpegTSContext *ts = s->priv_data;
     int ret, i;
 
+    pkt->size = -1;
     ts->pkt = pkt;
     ret = handle_packets(ts, 0);
     if (ret < 0) {
@@ -2037,6 +2038,8 @@ static int mpegts_read_packet(AVFormatContext *s,
         }
     }
 
+    if (!ret && pkt->size < 0)
+        ret = AVERROR(EINTR);
     return ret;
 }