[vlc-devel] commit: libvlc_InternalCreate: fix small race condition in error path ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun May 4 18:33:22 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Sun May  4 19:30:16 2008 +0300| [6d0788dcb77e2f31678dd307a16355cc505f7df4]

libvlc_InternalCreate: fix small race condition in error path

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

 src/libvlc-common.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/libvlc-common.c b/src/libvlc-common.c
index 46c8d44..4820619 100644
--- a/src/libvlc-common.c
+++ b/src/libvlc-common.c
@@ -158,9 +158,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
     /* Now that the thread system is initialized, we don't have much, but
      * at least we have variables */
     vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
-
-    i_instances++;
-
     if( !p_libvlc_global->b_ready )
     {
         /* Guess what CPU we have */
@@ -170,15 +167,16 @@ libvlc_int_t * libvlc_InternalCreate( void )
 
         p_libvlc_global->b_ready = true;
     }
-    vlc_mutex_unlock( lock );
 
     /* Allocate a libvlc instance object */
     p_libvlc = vlc_object_create( p_libvlc_global, VLC_OBJECT_LIBVLC );
+    if( p_libvlc != NULL )
+        i_instances++;
+    vlc_mutex_unlock( lock );
+
     if( p_libvlc == NULL )
-    {
-        i_instances--;
         return NULL;
-    }
+
     p_libvlc->p_playlist = NULL;
     p_libvlc->p_interaction = NULL;
     p_libvlc->p_vlm = NULL;




More information about the vlc-devel mailing list