[vlc-devel] commit: check malloc return value. (Jean-Paul Saman )

git version control git at videolan.org
Thu Aug 14 12:54:28 CEST 2008


vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Thu Aug 14 18:50:16 2008 +0800| [aed6c00efb251b3f1813d21ea39df5adfd8e8cc1] | committer: Jean-Paul Saman 

check malloc return value.

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

 src/control/media_list.c        |    7 +++----
 src/control/media_list_player.c |    5 ++++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/control/media_list.c b/src/control/media_list.c
index c379db9..8f84144 100644
--- a/src/control/media_list.c
+++ b/src/control/media_list.c
@@ -125,10 +125,9 @@ libvlc_media_list_new( libvlc_instance_t * p_inst,
     libvlc_media_list_t * p_mlist;
 
     p_mlist = malloc(sizeof(libvlc_media_list_t));
-
     if( !p_mlist )
         return NULL;
- 
+
     p_mlist->p_libvlc_instance = p_inst;
     p_mlist->p_event_manager = libvlc_event_manager_new( p_mlist, p_inst, p_e );
 
@@ -153,7 +152,7 @@ libvlc_media_list_new( libvlc_instance_t * p_inst,
     }
 
     vlc_mutex_init( &p_mlist->object_lock );
- 
+
     vlc_array_init( &p_mlist->items );
     p_mlist->i_refcount = 1;
     p_mlist->p_md = NULL;
@@ -405,7 +404,7 @@ void _libvlc_media_list_remove_index( libvlc_media_list_t * p_mlist,
         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 );
diff --git a/src/control/media_list_player.c b/src/control/media_list_player.c
index 2fd4a8a..c5f0451 100644
--- a/src/control/media_list_player.c
+++ b/src/control/media_list_player.c
@@ -261,6 +261,9 @@ libvlc_media_list_player_new( libvlc_instance_t * p_instance,
     (void)p_e;
     libvlc_media_list_player_t * p_mlp;
     p_mlp = malloc(sizeof(libvlc_media_list_player_t));
+    if( !p_mlp )
+        return NULL;
+
     p_mlp->current_playing_item_path = NULL;
     p_mlp->p_mi = NULL;
     p_mlp->p_mlist = NULL;
@@ -316,7 +319,7 @@ void libvlc_media_list_player_set_media_list(
                                      libvlc_exception_t * p_e )
 {
     vlc_mutex_lock( &p_mlp->object_lock );
- 
+
     if( libvlc_media_list_player_is_playing( p_mlp, p_e ) )
     {
         libvlc_media_player_stop( p_mlp->p_mi, p_e );




More information about the vlc-devel mailing list