avformat/flvenc: Check audio packet size
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 28 Jul 2018 13:03:50 +0000 (15:03 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 4 Aug 2018 14:17:01 +0000 (16:17 +0200)
Fixes: Assertion failure
Fixes: assert_flvenc.c:941_1.swf

Found-by: #CHEN HONGXU# <HCHEN017@e.ntu.edu.sg>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/flvenc.c

index 1c552a3..e4863f1 100644 (file)
@@ -883,6 +883,11 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
     int flags = -1, flags_size, ret;
     int64_t cur_offset = avio_tell(pb);
 
+    if (par->codec_type == AVMEDIA_TYPE_AUDIO && !pkt->size) {
+        av_log(s, AV_LOG_WARNING, "Empty audio Packet\n");
+        return AVERROR(EINVAL);
+    }
+
     if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A ||
         par->codec_id == AV_CODEC_ID_VP6  || par->codec_id == AV_CODEC_ID_AAC)
         flags_size = 2;