ogg: Fix potential infinite discard loop
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Sun, 18 Aug 2013 15:40:51 +0000 (17:40 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 19 Aug 2013 03:20:39 +0000 (05:20 +0200)
Seeking in certain broken files would cause ogg_read_timestamp
to fail because ogg_packet would go into a state where all packets
of stream 1 would be discarded until the end of the stream.

Bug-Id: 553
CC: libav-stable@libav.org
Signed-off-by: Jan Gerber <j@v2v.cc>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavformat/oggdec.c

index 6514c5b..d22d5bc 100644 (file)
@@ -384,7 +384,11 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,
 
         if (!complete && os->segp == os->nsegs) {
             ogg->curidx    = -1;
-            os->incomplete = 1;
+            // Do not set incomplete for empty packets.
+            // Together with the code in ogg_read_page
+            // that discards all continuation of empty packets
+            // we would get an infinite loop.
+            os->incomplete = !!os->psize;
         }
     } while (!complete);