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>
Tue, 4 Nov 2014 14:28:45 +0000 (09:28 -0500)
CC: libav-stable@libav.org
Bug-Id: CID 732250

libavcodec/aacsbr.c

index 0363aff..76c1014 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;