aacsbr: change order of operation to prevent out of array read
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 30 Oct 2014 00:52:04 +0000 (00:52 +0000)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 12 Jan 2015 23:06:07 +0000 (00:06 +0100)
CC: libav-stable@libav.org
Bug-Id: CID 732250

libavcodec/aacsbr.c

index 4d2ac6c..dbfb167 100644 (file)
@@ -549,7 +549,8 @@ static int sbr_hf_calc_npatches(AACContext *ac, SpectralBandReplication *sbr)
             k = sbr->n_master;
     } while (sb != sbr->kx[1] + sbr->m[1]);
 
-    if (sbr->patch_num_subbands[sbr->num_patches-1] < 3 && sbr->num_patches > 1)
+    if (sbr->num_patches > 1 &&
+        sbr->patch_num_subbands[sbr->num_patches - 1] < 3)
         sbr->num_patches--;
 
     return 0;