]> git.sesse.net Git - vlc/commitdiff
media_list.c: Fix crash showed by the new testapi tests.
authorPierre d'Herbemont <pdherbemont@free.fr>
Sun, 30 Mar 2008 00:59:26 +0000 (01:59 +0100)
committerPierre d'Herbemont <pdherbemont@free.fr>
Sun, 30 Mar 2008 00:59:26 +0000 (01:59 +0100)
src/control/media_list.c

index 4286fb942288cc536fe43eb146042fc4b742bc1e..e01b4a86a7d8a85519969a79bb0f9ca0eeddb818 100644 (file)
@@ -400,7 +400,7 @@ void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
 
     libvlc_media_descriptor_t * p_md;
 
-    if( index < 0 || index > vlc_array_count( &p_mlist->items ))
+    if( index < 0 || index >= vlc_array_count( &p_mlist->items ))
     {
         libvlc_exception_raise( p_e, "Index out of bounds exception");
         return;
@@ -427,6 +427,12 @@ libvlc_media_list_item_at_index( libvlc_media_list_t * p_mlist,
 {
     VLC_UNUSED(p_e);
 
+    if( index < 0 || index >= vlc_array_count( &p_mlist->items ))
+    {
+        libvlc_exception_raise( p_e, "Index out of bounds exception");
+        return NULL;
+    }
+
     libvlc_media_descriptor_t * p_md;
     p_md = vlc_array_item_at_index( &p_mlist->items, index );
     libvlc_media_descriptor_retain( p_md );