aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-12-09 16:16:46 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2015-12-09 18:27:54 +0100
commita9c721da12e39396066e28ddd6e35b8fc538f294 (patch)
treeb8480ca3c8a1709520b935fcc8aa4f1f76130004
parent4608cc176b34a0268785508a915c9860bbdd1f25 (diff)
downloadffmpeg-a9c721da12e39396066e28ddd6e35b8fc538f294.tar.gz
avformat/matroskaenc: Check codecdelay before use
Fixes CID1238790 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit e6971db12b8ae49712b77378fa8141de4904082b) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/matroskaenc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 2b2d034e00..7918346aee 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -926,14 +926,18 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv,
}
if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->initial_padding && codec->codec_id == AV_CODEC_ID_OPUS) {
+ int64_t codecdelay = av_rescale_q(codec->initial_padding,
+ (AVRational){ 1, codec->sample_rate },
+ (AVRational){ 1, 1000000000 });
+ if (codecdelay < 0) {
+ av_log(s, AV_LOG_ERROR, "Initial padding is invalid\n");
+ return AVERROR(EINVAL);
+ }
// mkv->tracks[i].ts_offset = av_rescale_q(codec->initial_padding,
// (AVRational){ 1, codec->sample_rate },
// st->time_base);
- put_ebml_uint(pb, MATROSKA_ID_CODECDELAY,
- av_rescale_q(codec->initial_padding,
- (AVRational){ 1, codec->sample_rate },
- (AVRational){ 1, 1000000000 }));
+ put_ebml_uint(pb, MATROSKA_ID_CODECDELAY, codecdelay);
}
if (codec->codec_id == AV_CODEC_ID_OPUS) {
put_ebml_uint(pb, MATROSKA_ID_SEEKPREROLL, OPUS_SEEK_PREROLL);