vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <r...@remlab.net> | Fri Nov 
14 19:20:53 2014 +0200| [13d9684ad44d519b3eb73c32d60a77f5a5a8773e] | committer: 
Rémi Denis-Courmont

ftp: fix leak

(cherry picked from commit f03324bb7ef555420b6b106a40ca833777072b26)

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

 modules/access/ftp.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index 90b2452..ce3cc79 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -309,7 +309,6 @@ static void clearCmdTLS( access_sys_t *p_sys )
 static int Login( vlc_object_t *p_access, access_sys_t *p_sys )
 {
     int i_answer;
-    char *psz;
 
     /* *** Open a TCP connection with server *** */
     int fd = p_sys->cmd.fd = net_ConnectTCP( p_access, p_sys->url.psz_host,
@@ -340,13 +339,6 @@ static int Login( vlc_object_t *p_access, access_sys_t 
*p_sys )
 
     msg_Dbg( p_access, "connection accepted (%d)", i_answer );
 
-    if( p_sys->url.psz_username && *p_sys->url.psz_username )
-        psz = strdup( p_sys->url.psz_username );
-    else
-        psz = var_InheritString( p_access, "ftp-user" );
-    if( !psz )
-        return -1;
-
     /* Features check first */
     if( ftp_SendCommand( p_access, p_sys, "FEAT" ) < 0
      || ftp_RecvAnswer( p_access, p_sys, NULL, NULL,
@@ -387,7 +379,6 @@ static int Login( vlc_object_t *p_access, access_sys_t 
*p_sys )
             i_answer != 200 )
         {
             msg_Err( p_access, "Can't truncate Protection buffer size for TLS" 
);
-            free( psz );
             goto error;
         }
 
@@ -396,12 +387,20 @@ static int Login( vlc_object_t *p_access, access_sys_t 
*p_sys )
             i_answer != 200 )
         {
             msg_Err( p_access, "Can't set Data channel protection" );
-            free( psz );
             goto error;
         }
     }
 
     /* Send credentials over channel */
+    char *psz;
+
+    if( p_sys->url.psz_username && *p_sys->url.psz_username )
+        psz = strdup( p_sys->url.psz_username );
+    else
+        psz = var_InheritString( p_access, "ftp-user" );
+    if( !psz )
+        goto error;
+
     if( ftp_SendCommand( p_access, p_sys, "USER %s", psz ) < 0 ||
         ftp_RecvCommand( p_access, p_sys, &i_answer, NULL ) < 0 )
     {

_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to