]> git.sesse.net Git - vlc/commitdiff
sftp: fix potential memory leak.
authorRémi Duraffort <ivoire@videolan.org>
Thu, 21 Apr 2011 16:59:53 +0000 (18:59 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Thu, 21 Apr 2011 16:59:53 +0000 (18:59 +0200)
modules/access/sftp.c

index 5b28dd2bc22c807c3ac1adabdacbde2ad958db37..573f689bb7fcffa0771094a2c24123e65101ae92 100644 (file)
@@ -153,7 +153,9 @@ static int Open( vlc_object_t* p_this )
     p_sys->i_socket = net_Connect( p_access, url.psz_host, i_port, SOCK_STREAM, 0 );
 
     /* Create the ssh connexion and wait until the server answer */
-    p_sys->ssh_session = libssh2_session_init();
+    if( ( p_sys->ssh_session = libssh2_session_init() ) == NULL )
+        goto error;
+
     while( ( i_ret = libssh2_session_startup( p_sys->ssh_session,
                                               p_sys->i_socket ) )
            == LIBSSH2_ERROR_EAGAIN );
@@ -250,6 +252,8 @@ static int Open( vlc_object_t* p_this )
     return VLC_SUCCESS;
 
 error:
+    if( p_sys->ssh_session )
+        libssh2_session_free( p_sys->ssh_session );
     free( psz_password );
     free( psz_username );
     vlc_UrlClean( &url );