[vlc-devel] commit: fix for #1533: check on array boundaries before removing media ( Filippo Carone )
git version control
git at videolan.org
Fri Mar 21 15:03:02 CET 2008
vlc | branch: master | Filippo Carone <littlejohn at videolan.org> | Fri Mar 21 15:03:29 2008 +0100| [709367d842d0c3c0b79e2fd125398d2147bd226e]
fix for #1533: check on array boundaries before removing media
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=709367d842d0c3c0b79e2fd125398d2147bd226e
---
.../test/java/org/videolan/jvlc/MediaListTest.java | 9 ++++++++-
src/control/media_list.c | 7 ++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/bindings/java/core/src/test/java/org/videolan/jvlc/MediaListTest.java b/bindings/java/core/src/test/java/org/videolan/jvlc/MediaListTest.java
index b5cb236..35cd1a9 100644
--- a/bindings/java/core/src/test/java/org/videolan/jvlc/MediaListTest.java
+++ b/bindings/java/core/src/test/java/org/videolan/jvlc/MediaListTest.java
@@ -99,7 +99,14 @@ public class MediaListTest
mlist.addMediaDescriptor(new MediaDescriptor(jvlc, mrl));
mlist.removeMedia(new MediaDescriptor(jvlc, mrl));
Assert.assertEquals(0, mlist.itemsCount());
-
+ }
+
+ @Test
+ public void mediaListRemoveNonExistingMedia()
+ {
+ MediaList mlist = new MediaList(jvlc);
+ boolean result = mlist.removeMedia(3);
+ Assert.assertFalse(result);
}
diff --git a/src/control/media_list.c b/src/control/media_list.c
index a88ed8c..4286fb9 100644
--- a/src/control/media_list.c
+++ b/src/control/media_list.c
@@ -397,10 +397,15 @@ void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
int index,
libvlc_exception_t * p_e )
{
- VLC_UNUSED(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 );
More information about the vlc-devel
mailing list