If chan2 is not smaller than the number of channels, it can cause segmentation faults due to dereferencing a NULL pointer.
Unified · Split
| @@ -806,6 +806,12 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data, · 805 unmodified lines | |||
| 806 | if (s->mcdparams[i].present) { | 806 | if (s->mcdparams[i].present) { |
| 807 | s->mcdparams[i].index = get_bits(gb, 2); | 807 | s->mcdparams[i].index = get_bits(gb, 2); |
| 808 | s->mcdparams[i].chan2 = get_bits(gb, 4); | 808 | s->mcdparams[i].chan2 = get_bits(gb, 4); |
| 809 | if (s->mcdparams[i].chan2 >= avctx->channels) { | ||
| 810 | av_log(avctx, AV_LOG_ERROR, | ||
| 811 | "invalid channel 2 (%d) for %d channel(s)\n", | ||
| 812 | s->mcdparams[i].chan2, avctx->channels); | ||
| 813 | return AVERROR_INVALIDDATA; | ||
| 814 | } | ||
| 809 | if (s->mcdparams[i].index == 1) { | 815 | if (s->mcdparams[i].index == 1) { |
| 810 | if ((nbit == s->mcdparams[i].chan2) || | 816 | if ((nbit == s->mcdparams[i].chan2) || |
| 811 | (ch_mask & 1 << s->mcdparams[i].chan2)) | 817 | (ch_mask & 1 << s->mcdparams[i].chan2)) |