[vlc-devel] commit: Rework to use asprintf() in live555 demux (Jean-Paul Saman )

git version control git at videolan.org
Tue Apr 22 16:10:00 CEST 2008


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Thu Apr 17 14:52:53 2008 +0200| [d58fbdad0e5332b948ccac1f796df27872959d45]

Rework to use asprintf() in live555 demux

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

 modules/demux/live555.cpp |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/modules/demux/live555.cpp b/modules/demux/live555.cpp
index e2f1a69..b9e4d4b 100644
--- a/modules/demux/live555.cpp
+++ b/modules/demux/live555.cpp
@@ -457,8 +457,7 @@ static int Connect( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     Authenticator authenticator;
-    bool b_firstpass = true;
-
+    bool b_firstpass  = true;
     char *psz_user    = NULL;
     char *psz_pwd     = NULL;
     char *psz_url     = NULL;
@@ -466,28 +465,30 @@ static int Connect( demux_t *p_demux )
     char *p_sdp       = NULL;
     int  i_http_port  = 0;
     int  i_ret        = VLC_SUCCESS;
-
-    psz_url = (char*)malloc( strlen( p_sys->psz_path ) + 8 );
-    if( !psz_url ) return VLC_ENOMEM;
+    int i_lefttries;
 
     if( p_sys->url.i_port == 0 ) p_sys->url.i_port = 554;
     if( p_sys->url.psz_username || p_sys->url.psz_password )
     {
-        sprintf( psz_url, "rtsp://%s:%d%s", p_sys->url.psz_host,
-                 p_sys->url.i_port, p_sys->url.psz_path );
+        int err;
+        err = asprintf( &psz_url, "rtsp://%s:%d%s", p_sys->url.psz_host,
+                        p_sys->url.i_port, p_sys->url.psz_path );
+        if( err == -1 ) return VLC_ENOMEM;
 
         psz_user = strdup( p_sys->url.psz_username );
         psz_pwd  = strdup( p_sys->url.psz_password );
     }
     else
     {
-        sprintf( psz_url, "rtsp://%s", p_sys->psz_path );
+        int err;
+        err = asprintf( &psz_url, "rtsp://%s", p_sys->psz_path );
+        if( err == -1 ) return VLC_ENOMEM;
 
         psz_user = var_CreateGetString( p_demux, "rtsp-user" );
         psz_pwd  = var_CreateGetString( p_demux, "rtsp-pwd" );
     }
 
-    int i_lefttries = 3;
+    i_lefttries = 3;
 createnew:
     i_lefttries--;
     if( p_demux->b_die || p_demux->b_error )




More information about the vlc-devel mailing list