]> git.sesse.net Git - vlc/blobdiff - src/control/media_list.c
fix for #1533: check on array boundaries before removing media
[vlc] / src / control / media_list.c
index 407ecf4d10b0721119428c68916a03087af4dbba..4286fb942288cc536fe43eb146042fc4b742bc1e 100644 (file)
@@ -397,8 +397,15 @@ void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
                                      int index,
                                      libvlc_exception_t * p_e )
 {
+
     libvlc_media_descriptor_t * p_md;
 
+    if( index < 0 || index > vlc_array_count( &p_mlist->items ))
+    {
+        libvlc_exception_raise( p_e, "Index out of bounds exception");
+        return;
+    }
+            
     p_md = vlc_array_item_at_index( &p_mlist->items, index );
 
     notify_item_deletion( p_mlist, p_md, index, EventWillHappen );
@@ -418,6 +425,8 @@ libvlc_media_list_item_at_index( libvlc_media_list_t * p_mlist,
                                  int index,
                                  libvlc_exception_t * p_e )
 {
+    VLC_UNUSED(p_e);
+
     libvlc_media_descriptor_t * p_md;
     p_md = vlc_array_item_at_index( &p_mlist->items, index );
     libvlc_media_descriptor_retain( p_md );
@@ -434,6 +443,8 @@ int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist,
                                      libvlc_media_descriptor_t * p_searched_md,
                                      libvlc_exception_t * p_e )
 {
+    VLC_UNUSED(p_e);
+
     libvlc_media_descriptor_t * p_md;
     int i;
     for ( i = 0; i < vlc_array_count( &p_mlist->items ); i++ )
@@ -450,7 +461,7 @@ int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist,
  *
  * This indicates if this media list is read-only from a user point of view
  **************************************************************************/
-vlc_bool_t libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist )
+int libvlc_media_list_is_readonly( libvlc_media_list_t * p_mlist )
 {
     return p_mlist->b_read_only;
 }