Ticket #3581: mc-3581-sftp-fix-connection-memleaks-0003.patch

File mc-3581-sftp-fix-connection-memleaks-0003.patch, 1.8 KB (added by and, 8 years ago)
  • src/vfs/sftpfs/connection.c

    From 46dfe207e64bf7dc2bcf58cf3757c20558625546 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sun, 3 Jan 2016 17:33:56 +0000
    Subject: [PATCH 03/05] sftp: fix connection memleaks (cosmetic)
    
       sftpfs_super_data created at sftpfs_cb_open_connection() was freed at sftpfs_close_connection()
       it should be sftpfs_cb_close_connection() for logical right location
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/vfs/sftpfs/connection.c   | 3 ---
     src/vfs/sftpfs/vfs_subclass.c | 7 +++++++
     2 files changed, 7 insertions(+), 3 deletions(-)
    
    diff --git a/src/vfs/sftpfs/connection.c b/src/vfs/sftpfs/connection.c
    index 3bed24e..b3fe4d0 100644
    a b sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message 
    442442    if (super_data == NULL) 
    443443        return; 
    444444 
    445     vfs_path_element_free (super_data->original_connection_info); 
    446     super_data->original_connection_info = NULL; 
    447  
    448445    if (super_data->agent != NULL) 
    449446    { 
    450447        libssh2_agent_disconnect (super_data->agent); 
  • src/vfs/sftpfs/vfs_subclass.c

    diff --git a/src/vfs/sftpfs/vfs_subclass.c b/src/vfs/sftpfs/vfs_subclass.c
    index 8ddff74..85e552d 100644
    a b static void 
    137137sftpfs_cb_close_connection (struct vfs_class *me, struct vfs_s_super *super) 
    138138{ 
    139139    GError *mcerror = NULL; 
     140    sftpfs_super_data_t *sftpfs_super_data; 
    140141 
    141142    (void) me; 
    142143    sftpfs_close_connection (super, "Normal Shutdown", &mcerror); 
     144 
     145    sftpfs_super_data = (sftpfs_super_data_t *) super->data; 
     146    if (sftpfs_super_data != NULL) 
     147        vfs_path_element_free (sftpfs_super_data->original_connection_info); 
     148 
    143149    mc_error_message (&mcerror, NULL); 
     150 
    144151    g_free (super->data); 
    145152} 
    146153