You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
shorten: check output buffer size before decoding
This commit is contained in:
@@ -550,9 +550,15 @@ static int shorten_decode_frame(AVCodecContext *avctx,
|
|||||||
/* if this is the last channel in the block, output the samples */
|
/* if this is the last channel in the block, output the samples */
|
||||||
s->cur_chan++;
|
s->cur_chan++;
|
||||||
if (s->cur_chan == s->channels) {
|
if (s->cur_chan == s->channels) {
|
||||||
|
int out_size = s->blocksize * s->channels *
|
||||||
|
av_get_bytes_per_sample(avctx->sample_fmt);
|
||||||
|
if (*data_size < out_size) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded);
|
samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded);
|
||||||
s->cur_chan = 0;
|
s->cur_chan = 0;
|
||||||
*data_size = (int8_t *)samples - (int8_t *)data;
|
*data_size = out_size;
|
||||||
} else {
|
} else {
|
||||||
*data_size = 0;
|
*data_size = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user