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

Jean-Baptiste Kempf git at videolan.org
Sat Nov 15 00:00:12 CET 2014


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

libass: avoid negative index in array

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

 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 9ea4f38..f6f14a6 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