[FFmpeg-cvslog] alsdec: ensure channel reordering is reversible

Andreas Cadhalpun git at videolan.org
Sun Apr 19 04:33:44 CEST 2015


ffmpeg | branch: release/2.5 | Andreas Cadhalpun <andreas.cadhalpun at googlemail.com> | Sat Apr 18 18:31:36 2015 +0200| [96c1421627aad9e9216e0d5d50419a880bdc34ee] | committer: 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: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit ef16501aebed43e34a3721336e8bee732eca2877)

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96c1421627aad9e9216e0d5d50419a880bdc34ee
---

 libavcodec/alsdec.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index cfece44..e539795 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -358,10 +358,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;



More information about the ffmpeg-cvslog mailing list