[vlc-commits] libass: avoid negative index in array

Jean-Baptiste Kempf git at videolan.org
Thu Nov 20 19:49:24 CET 2014


vlc/vlc-2.2 | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Fri Nov 14 23:50:52 2014 +0100| [5f26e7d35cbb37951678313174b6db689b88e4e0] | committer: Jean-Baptiste Kempf

libass: avoid negative index in array

(cherry picked from commit e91ea1f9c3f5575c65003818b6b0c2948435c2b8)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=5f26e7d35cbb37951678313174b6db689b88e4e0
---

 modules/codec/libass.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
index 5590df1..dc247f4 100644
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -627,11 +627,14 @@ static int BuildRegions( rectangle_t *p_region, int i_max_region, ASS_Image *p_i
 #ifdef DEBUG_REGION
             msg_Err( p_spu, "Merging %d and %d", i_best_i, i_best_j );
 #endif
-            r_add( &region[i_best_i], &region[i_best_j] );
+            if( i_best_j >= 0 && i_best_i >= 0 )
+            {
+                r_add( &region[i_best_i], &region[i_best_j] );
 
-            if( i_best_j+1 < i_region )
-                memmove( &region[i_best_j], &region[i_best_j+1], sizeof(*region) * ( i_region - (i_best_j+1)  ) );
-            i_region--;
+                if( i_best_j+1 < i_region )
+                    memmove( &region[i_best_j], &region[i_best_j+1], sizeof(*region) * ( i_region - (i_best_j+1)  ) );
+                i_region--;
+            }
         }
     }
 



More information about the vlc-commits mailing list