aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-08-27 04:08:42 +0200
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2015-10-10 01:14:58 +0200
commit0b0183c5b741afea80fefef662d61e32e21a09c6 (patch)
treef16a8fcd4518391b773d61f88509e48d0a53ea74
parent055c302a11cdf78d2e31ddfc7ef3be6f46eaa6a0 (diff)
downloadffmpeg-0b0183c5b741afea80fefef662d61e32e21a09c6.tar.gz
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 81a8701eb52d2b6469ae16ef442ce425388141b7)
-rw-r--r--libavformat/oggenc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 1255364259..a92fc6c22e 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -256,7 +256,7 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
if (i == total_segments)
page->granule = granule;
- if (!header) {
+ {
AVStream *st = s->streams[page->stream_index];
int64_t start = av_rescale_q(page->start_granule, st->time_base,
@@ -264,10 +264,13 @@ static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
int64_t next = av_rescale_q(page->granule, st->time_base,
AV_TIME_BASE_Q);
- if (page->segments_count == 255 ||
- (ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
- (ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
+ if (page->segments_count == 255) {
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_buffer_page(s, oggstream);
+ }
}
}
}