[vlc-commits] lib: avoid NULL deref on error

Rémi Denis-Courmont git at videolan.org
Wed Apr 23 18:42:11 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr 23 19:41:54 2014 +0300| [8c9e80fb1f9c848e61105a304a74c26664383311] | committer: Rémi Denis-Courmont

lib: avoid NULL deref on error

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

 lib/media.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/media.c b/lib/media.c
index af70b4a..bac11da 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -113,15 +113,14 @@ static void input_item_subitem_added( const vlc_event_t *p_event,
                 p_event->u.input_item_subitem_added.p_new_child );
 
     /* Add this to our media list */
-    if( !p_md->p_subitems )
+    if( p_md->p_subitems == NULL )
     {
         p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance );
+        if( unlikely(p_md->p_subitems == NULL) )
+            abort();
         libvlc_media_list_set_media( p_md->p_subitems, p_md );
     }
-    if( p_md->p_subitems )
-    {
-        libvlc_media_list_add_media( p_md->p_subitems, p_md_child );
-    }
+    libvlc_media_list_add_media( p_md->p_subitems, p_md_child );
 
     /* Construct the event */
     event.type = libvlc_MediaSubItemAdded;



More information about the vlc-commits mailing list