Browse Source

Fix potential infinite discard loop.

Fixes trac issue #438.
Seeking in that sample 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.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
tags/n0.11
Reimar Döffinger 13 years ago
parent
commit
d7b542ae29
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      libavformat/oggdec.c

+ 8
- 1
libavformat/oggdec.c View File

@@ -282,6 +282,9 @@ static int ogg_read_page(AVFormatContext *s, int *str)


if (flags & OGG_FLAG_CONT || os->incomplete){ if (flags & OGG_FLAG_CONT || os->incomplete){
if (!os->psize){ if (!os->psize){
// If this is the very first segment we started
// playback in the middle of a continuation packet.
// Discard it since we missed the start of it.
while (os->segp < os->nsegs){ while (os->segp < os->nsegs){
int seg = os->segments[os->segp++]; int seg = os->segments[os->segp++];
os->pstart += seg; os->pstart += seg;
@@ -368,7 +371,11 @@ static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize,


if (!complete && os->segp == os->nsegs){ if (!complete && os->segp == os->nsegs){
ogg->curidx = -1; 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); }while (!complete);




Loading…
Cancel
Save