ac3: Check the array bound before dereferencing
authorLuca Barbato <lu_zero@gentoo.org>
Thu, 26 May 2016 00:41:25 +0000 (02:41 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Fri, 27 May 2016 13:49:48 +0000 (15:49 +0200)
CC: libav-stable@libav.org
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/ac3enc_template.c

index 8febf85..ec8ec4e 100644 (file)
@@ -260,7 +260,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];