[vlc-commits] sftp: fix potential memory leak.

Rémi Duraffort git at videolan.org
Thu Apr 21 19:00:15 CEST 2011


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Thu Apr 21 18:59:53 2011 +0200| [98195bf4971383d5cc8399c5c47b7295b80927dd] | committer: Rémi Duraffort

sftp: fix potential memory leak.

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

 modules/access/sftp.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index 5b28dd2..573f689 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -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 );



More information about the vlc-commits mailing list