[FFmpeg-devel] [PATCH] avformat/rawenc: avoid divide by 0 when writing adx trailer

Andriy Gelman andriy.gelman at gmail.com
Sat Jul 13 23:50:37 EEST 2019


From: Andriy Gelman <andriy.gelman at gmail.com>

Fixes #7985
This patch checks that the number of audio channels is not zero when
writing the total sample count in adx header.
---
 libavformat/rawenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 993d232b70..bf8537fffb 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -65,6 +65,9 @@ static int adx_write_trailer(AVFormatContext *s)
     AVIOContext *pb = s->pb;
     AVCodecParameters *par = s->streams[0]->codecpar;
 
+    if (par->channels == 0)
+      return AVERROR_INVALIDDATA;
+
     if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
         int64_t file_size = avio_tell(pb);
         uint64_t sample_count = (file_size - 36) / par->channels / 18 * 32;
-- 
2.22.0



More information about the ffmpeg-devel mailing list