mirror of https://git.ffmpeg.org/ffmpeg.git
avformat/oggenc: Check segments_count for headers too
Fixes infinite loop and segfault in ogg_buffer_data()
Fixes Ticket4806
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 81a8701eb5
)
This commit is contained in:
parent
0cdeacf41b
commit
30c644afeb
|
@ -256,7 +256,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
|
||||||
if (i == total_segments)
|
if (i == total_segments)
|
||||||
page->granule = granule;
|
page->granule = granule;
|
||||||
|
|
||||||
if (!header) {
|
{
|
||||||
AVStream *st = s->streams[page->stream_index];
|
AVStream *st = s->streams[page->stream_index];
|
||||||
|
|
||||||
int64_t start = av_rescale_q(page->start_granule, st->time_base,
|
int64_t start = av_rescale_q(page->start_granule, st->time_base,
|
||||||
|
@ -264,13 +264,16 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
|
||||||
int64_t next = av_rescale_q(page->granule, st->time_base,
|
int64_t next = av_rescale_q(page->granule, st->time_base,
|
||||||
AV_TIME_BASE_Q);
|
AV_TIME_BASE_Q);
|
||||||
|
|
||||||
if (page->segments_count == 255 ||
|
if (page->segments_count == 255) {
|
||||||
(ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
|
ogg_buffer_page(s, oggstream);
|
||||||
|
} else if (!header) {
|
||||||
|
if ((ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
|
||||||
(ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
|
(ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
|
||||||
ogg_buffer_page(s, oggstream);
|
ogg_buffer_page(s, oggstream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flush && oggstream->page.granule != -1)
|
if (flush && oggstream->page.granule != -1)
|
||||||
ogg_buffer_page(s, oggstream);
|
ogg_buffer_page(s, oggstream);
|
||||||
|
|
Loading…
Reference in New Issue