[vlc-devel] commit: Use asprintf and check it. ( Rémi Duraffort )

git version control git at videolan.org
Tue Oct 28 22:43:11 CET 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Oct 26 22:41:49 2008 +0100| [de3f8c025b7bcee3d784a8b9c43d6f1fc1bbb62e] | committer: Rémi Duraffort 

Use asprintf and check it.

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

 src/interface/interface.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/interface/interface.c b/src/interface/interface.c
index b850eeb..3e3cc36 100644
--- a/src/interface/interface.c
+++ b/src/interface/interface.c
@@ -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 )




More information about the vlc-devel mailing list