ac3: Check the array bound before dereferencing

Message ID 20160528034136.A41235DB0B@aruru.libav.org
State New
Headers show

Commit Message

Janne Grunau May 28, 2016, 3:41 a.m.
Module: libav
Branch: master
Commit: 5264e7ba217b3c0ceae813917134e1ab52573141

Author:    Luca Barbato <lu_zero@gentoo.org>
Committer: Luca Barbato <lu_zero@gentoo.org>
Date:      Thu May 26 02:41:25 2016 +0200

ac3: Check the array bound before dereferencing

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>

---

 libavcodec/ac3enc_template.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index 8febf85..ec8ec4e 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -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];