Commit a2d1922b authored by Andreas Cadhalpun's avatar Andreas Cadhalpun Committed by Luca Barbato

takdec: ensure chan2 is a valid channel index

If chan2 is not smaller than the number of channels, it can cause
segmentation faults due to dereferencing a NULL pointer.
Signed-off-by: 's avatarAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 9765549f
...@@ -806,6 +806,12 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, ...@@ -806,6 +806,12 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
if (s->mcdparams[i].present) { if (s->mcdparams[i].present) {
s->mcdparams[i].index = get_bits(gb, 2); s->mcdparams[i].index = get_bits(gb, 2);
s->mcdparams[i].chan2 = get_bits(gb, 4); s->mcdparams[i].chan2 = get_bits(gb, 4);
if (s->mcdparams[i].chan2 >= avctx->channels) {
av_log(avctx, AV_LOG_ERROR,
"invalid channel 2 (%d) for %d channel(s)\n",
s->mcdparams[i].chan2, avctx->channels);
return AVERROR_INVALIDDATA;
}
if (s->mcdparams[i].index == 1) { if (s->mcdparams[i].index == 1) {
if ((nbit == s->mcdparams[i].chan2) || if ((nbit == s->mcdparams[i].chan2) ||
(ch_mask & 1 << s->mcdparams[i].chan2)) (ch_mask & 1 << s->mcdparams[i].chan2))
......
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