Commit ef16501a authored by Andreas Cadhalpun's avatar Andreas Cadhalpun Committed by Michael Niedermayer

alsdec: ensure channel reordering is reversible

If the same idx is used for more than one i, at least one entry in
sconf->chan_pos remains uninitialized.

This can cause segmentation faults.
Signed-off-by: 's avatarAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent d8c52f5d
...@@ -357,11 +357,15 @@ static av_cold int read_specific_config(ALSDecContext *ctx) ...@@ -357,11 +357,15 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
ctx->cs_switch = 1; ctx->cs_switch = 1;
for (i = 0; i < avctx->channels; i++) {
sconf->chan_pos[i] = -1;
}
for (i = 0; i < avctx->channels; i++) { for (i = 0; i < avctx->channels; i++) {
int idx; int idx;
idx = get_bits(&gb, chan_pos_bits); idx = get_bits(&gb, chan_pos_bits);
if (idx >= avctx->channels) { if (idx >= avctx->channels || sconf->chan_pos[idx] != -1) {
av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n"); av_log(avctx, AV_LOG_WARNING, "Invalid channel reordering.\n");
ctx->cs_switch = 0; ctx->cs_switch = 0;
break; break;
......
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