[vlc-devel] commit: Do not allocate unbound array on the stack. (Laurent Aimar )

git version control git at videolan.org
Tue Aug 5 00:33:30 CEST 2008


vlc | branch: 0.9.0-libass | Laurent Aimar <fenrir at videolan.org> | Tue Aug  5 00:26:38 2008 +0200| [64a820ebf8ca20989f50fc1acc6676cb465f3103] | committer: Laurent Aimar 

Do not allocate unbound array on the stack.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=64a820ebf8ca20989f50fc1acc6676cb465f3103
---

 modules/codec/libass.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index 8dc748f..90a0dc5 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -446,6 +446,8 @@ static int BuildRegions( spu_t *p_spu, rectangle_t *p_region, int i_max_region,
     ass_image_t *p_tmp;
     int i_count;
 
+    VLC_UNUSED(p_spu);
+
 #ifdef DEBUG_REGION
     int64_t i_ck_start = mdate();
 #endif
@@ -455,7 +457,10 @@ static int BuildRegions( spu_t *p_spu, rectangle_t *p_region, int i_max_region,
     if( i_count <= 0 )
         return 0;
 
-    ass_image_t *pp_img[i_count];   // TODO move to context ?
+    ass_image_t **pp_img = calloc( i_count, sizeof(*pp_img) );
+    if( !pp_img )
+        return 0;
+
     for( p_tmp = p_img_list, i_count = 0; p_tmp != NULL; p_tmp = p_tmp->next, i_count++ )
         pp_img[i_count] = p_tmp;
 
@@ -556,6 +561,8 @@ static int BuildRegions( spu_t *p_spu, rectangle_t *p_region, int i_max_region,
     msg_Err( p_spu, "ASS: %d objects merged into %d region in %d micros", i_count, i_region, (int)(i_ck_time) );
 #endif
 
+    free( pp_img );
+
     return i_region;
 }
 




More information about the vlc-devel mailing list