avcodec/ac3enc_template: fix out of array read
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 27 Sep 2014 18:34:44 +0000 (20:34 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 21 Dec 2014 03:40:03 +0000 (04:40 +0100)
Found-by: Andreas Cadhalpun
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit d85ebea3f3b68ebccfe308fa839fc30fa634e4de)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/ac3enc_template.c

index 904e0bb..5b06531 100644 (file)
@@ -259,7 +259,7 @@ static void apply_channel_coupling(AC3EncodeContext *s)
                 energy_cpl = energy[blk][CPL_CH][bnd];
                 energy_ch = energy[blk][ch][bnd];
                 blk1 = blk+1;
-                while (!s->blocks[blk1].new_cpl_coords[ch] && blk1 < s->num_blocks) {
+                while (blk1 < s->num_blocks && !s->blocks[blk1].new_cpl_coords[ch]) {
                     if (s->blocks[blk1].cpl_in_use) {
                         energy_cpl += energy[blk1][CPL_CH][bnd];
                         energy_ch += energy[blk1][ch][bnd];