summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cadhalpun <andreas.cadhalpun@googlemail.com>2015-04-18 18:31:36 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-22 12:27:25 +0200
commitbfd65092a2b7fc1ae95e8fe79c7f0a61f25b111b (patch)
treeb8efcaec018c0f3998892f10ca3665ef07f6e865
parent307c5cb9d4cc3b9373cac5b00ebdc28fc0d593fe (diff)
downloadffmpeg-bfd65092a2b7fc1ae95e8fe79c7f0a61f25b111b.tar.gz
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: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit ef16501aebed43e34a3721336e8bee732eca2877) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/alsdec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index a2b4be5691..c0367d4ba2 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -356,10 +356,14 @@ static av_cold int read_specific_config(ALSDecContext *ctx)
ctx->cs_switch = 1;
for (i = 0; i < avctx->channels; i++) {
+ sconf->chan_pos[i] = -1;
+ }
+
+ for (i = 0; i < avctx->channels; i++) {
int idx;
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");
ctx->cs_switch = 0;
break;