]> git.sesse.net Git - vlc/commitdiff
Use asprintf and check it.
authorRémi Duraffort <ivoire@videolan.org>
Sun, 26 Oct 2008 21:41:49 +0000 (22:41 +0100)
committerRémi Duraffort <ivoire@videolan.org>
Tue, 28 Oct 2008 21:42:37 +0000 (22:42 +0100)
src/interface/interface.c

index b850eeb4102923768ca29298f5d4229b5522c68e..3e3cc36b07932d8ae3a1c9c7730076e31d4bcca4 100644 (file)
@@ -271,13 +271,14 @@ static void * MonitorLibVLCDeath( vlc_object_t * p_this )
 static int AddIntfCallback( vlc_object_t *p_this, char const *psz_cmd,
                          vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
-    intf_thread_t *p_intf;
-    char *psz_intf = malloc( strlen(newval.psz_string) + sizeof(",none") );
-
     (void)psz_cmd; (void)oldval; (void)p_data;
+    intf_thread_t *p_intf;
+    char* psz_intf;
 
     /* Try to create the interface */
-    sprintf( psz_intf, "%s,none", newval.psz_string );
+    if( asprintf( &psz_intf, "%s,none", newval.psz_string ) == -1 )
+        return VLC_ENOMEM;
+
     p_intf = intf_Create( p_this->p_libvlc, psz_intf );
     free( psz_intf );
     if( p_intf == NULL )