[vlc-devel] commit: Fix object leaking in libvlc_new() (Jean-Paul Saman )

git version control git at videolan.org
Mon Oct 27 16:23:27 CET 2008


vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Tue Oct 21 10:24:56 2008 +0200| [36bfe4239652f1a4a50467ddda8104a60e19a2bb] | committer: Jean-Paul Saman 

Fix object leaking in libvlc_new()

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

 src/control/core.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/control/core.c b/src/control/core.c
index b0590ba..c3072aa 100644
--- a/src/control/core.c
+++ b/src/control/core.c
@@ -89,15 +89,22 @@ libvlc_instance_t * libvlc_new( int argc, char **argv,
     i_vlc_id = VLC_Create();
     p_vlc = (vlc_t* ) vlc_current_object( i_vlc_id );
 
-    if( !p_vlc ) RAISENULL( "VLC initialization failed" );
+    if( !p_vlc )
+    {
+        libvlc_exception_raise( p_e, "VLC initialization failed" );
+        return NULL;
+    }
 
     p_new = (libvlc_instance_t *)malloc( sizeof( libvlc_instance_t ) );
-    if( !p_new ) RAISENULL( "Out of memory" );
-
+    if( !p_new )
+    {
+       libvlc_exception_raise( p_e, "Out of memory" );
+       VLC_Destroy( p_vlc );
+       return NULL;
+    }
     /** \todo Look for interface settings. If we don't have any, add -I dummy */
     /* Because we probably don't want a GUI by default */
 
-
     VLC_Init( i_vlc_id, argc, argv );
 
     p_new->p_vlc = p_vlc;
@@ -108,7 +115,8 @@ libvlc_instance_t * libvlc_new( int argc, char **argv,
     if( !p_new->p_playlist )
     {
         libvlc_destroy( p_new );
-        RAISENULL( "Playlist creation failed" );
+        libvlc_exception_raise( p_e, "Playlist creation failed" );
+        return NULL;
     }
 
     p_new->i_vlc_id = i_vlc_id;
@@ -129,4 +137,3 @@ int libvlc_get_vlc_id( libvlc_instance_t *p_instance )
 {
     return p_instance->i_vlc_id;
 }
-




More information about the vlc-devel mailing list