[FFmpeg-soc] [soc]: r5461 - aac-sbr/aacsbr.c

alexc subversion at mplayerhq.hu
Thu Nov 26 22:52:58 CET 2009


Author: alexc
Date: Thu Nov 26 22:52:58 2009
New Revision: 5461

Log:
Allocate vk0 and vk1 on the stack to prevent memory leaks.

Modified:
   aac-sbr/aacsbr.c

Modified: aac-sbr/aacsbr.c
==============================================================================
--- aac-sbr/aacsbr.c	Thu Nov 26 22:52:56 2009	(r5460)
+++ aac-sbr/aacsbr.c	Thu Nov 26 22:52:58 2009	(r5461)
@@ -240,7 +240,7 @@ static int sbr_make_f_master(AACContext 
         float warp = spectrum->bs_alter_scale ? 1.3 : 1.0;        // bs_alter_scale = {0,1}
         unsigned int two_regions, num_bands_0;
         int vdk0_max, vdk1_min;
-        int *vk0;
+        int vk0[49];
 
         if (sbr->k[2] / (float)sbr->k[0] > 2.2449) {
             two_regions = 1;
@@ -257,7 +257,6 @@ static int sbr_make_f_master(AACContext 
             return -1;
         }
 
-        vk0 = av_malloc((num_bands_0 + 1) * sizeof(int));
         vk0[0] = 0;
 
         for (k = 0; k < num_bands_0; k++) {
@@ -278,12 +277,10 @@ static int sbr_make_f_master(AACContext 
         }
 
         if (two_regions) {
-            int *vk1;
+            int vk1[49];
             unsigned int num_bands_1 = lroundf(bands * logf(sbr->k[2] / (float)sbr->k[1]) /
                                               (2.0f * logf(2.0f) * warp)) << 1;
 
-            vk1 = av_malloc((num_bands_1 + 1) * sizeof(int));
-
             for (k = 0; k < num_bands_1; k++) {
                 vk1[k + 1] = lroundf(sbr->k[1] * powf(sbr->k[2] / (float)sbr->k[1], (k + 1) / (float)num_bands_1)) -
                              lroundf(sbr->k[1] * powf(sbr->k[2] / (float)sbr->k[1],  k      / (float)num_bands_1));
@@ -314,12 +311,10 @@ static int sbr_make_f_master(AACContext 
             memcpy(&sbr->f_master[0],               vk0,    (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
             memcpy(&sbr->f_master[num_bands_0 + 1], vk1 + 1, num_bands_1      * sizeof(sbr->f_master[0]));
 
-            av_free(vk1);
         } else {
             sbr->n_master = num_bands_0;
             memcpy(sbr->f_master, vk0, (num_bands_0 + 1) * sizeof(sbr->f_master[0]));
         }
-        av_free(vk0);
     }
     // Requirements (14496-3 sp04 p205)
     if (sbr->spectrum_params[1].bs_xover_band >= sbr->n_master) {


More information about the FFmpeg-soc mailing list