Commit db6e337b authored by Paul B Mahol's avatar Paul B Mahol

avcodec/s302menc: check if buf_size can actually be put into 16bit size

This disallows creating unplayable audio.
Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 577f0573
...@@ -78,6 +78,11 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -78,6 +78,11 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt,
uint8_t *o; uint8_t *o;
PutBitContext pb; PutBitContext pb;
if (buf_size - AES3_HEADER_LEN > UINT16_MAX) {
av_log(avctx, AV_LOG_ERROR, "number of samples in frame too big\n");
return AVERROR(EINVAL);
}
if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size, 0)) < 0) if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size, 0)) < 0)
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment