[vlc-devel] commit: Check asprintf return value. ( Rémi Duraffort )

git version control git at videolan.org
Sun Aug 17 21:50:13 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Aug 17 21:47:00 2008 +0200| [48c7e2ce1920c0c4b59b967397c256c098e06a54] | committer: Rémi Duraffort 

Check asprintf return value.

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

 modules/access/smb.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/modules/access/smb.c b/modules/access/smb.c
index 3f21b6b..b5f518b 100644
--- a/modules/access/smb.c
+++ b/modules/access/smb.c
@@ -198,21 +198,24 @@ static int Open( vlc_object_t *p_this )
 #ifdef WIN32
     if( psz_user )
         Win32AddConnection( p_access, psz_path, psz_user, psz_pwd, psz_domain);
-    asprintf( &psz_uri, "//%s", psz_path );
+    i_ret = asprintf( &psz_uri, "//%s", psz_path );
 #else
     if( psz_user )
-        asprintf( &psz_uri, "smb://%s%s%s%s%s@%s",
-                  psz_domain ? psz_domain : "", psz_domain ? ";" : "",
-                  psz_user, psz_pwd ? ":" : "",
-                  psz_pwd ? psz_pwd : "", psz_path );
+        i_ret = asprintf( &psz_uri, "smb://%s%s%s%s%s@%s",
+                          psz_domain ? psz_domain : "", psz_domain ? ";" : "",
+                          psz_user, psz_pwd ? ":" : "",
+                          psz_pwd ? psz_pwd : "", psz_path );
     else
-        asprintf( &psz_uri, "smb://%s", psz_path );
+        i_ret = asprintf( &psz_uri, "smb://%s", psz_path );
 #endif
 
     free( psz_user );
     free( psz_pwd );
     free( psz_domain );
 
+    if( i_ret == -1 )
+        return VLC_ENOMEM;
+
 #ifdef USE_CTX
     if( !(p_smb = smbc_new_context()) )
     {




More information about the vlc-devel mailing list