From c5f335ad4f89a05126977ea3dc6714640a62e089 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 24 May 2009 23:44:52 +0200 Subject: [PATCH] Fix my recent session->sftpInit_sftp fix which wasn't correct. The memory area does not need to be freed (it already gets freed) but clearing the pointer is a good idea. And it should be done _after_ the channel_free() call. --- src/sftp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/sftp.c b/src/sftp.c index a9ca3788..b8adfb27 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -791,12 +791,14 @@ sftp_shutdown(LIBSSH2_SFTP *sftp) LIBSSH2_FREE(session, sftp->symlink_packet); sftp->symlink_packet = NULL; } - if (session->sftpInit_sftp) { - LIBSSH2_FREE(session, session->sftpInit_sftp); - session->sftpInit_sftp = NULL; - } + rc = _libssh2_channel_free(sftp->channel); + if (session->sftpInit_sftp) + /* the SFTP stuff is freed by the stored "destructor" as part of the + channel free magic */ + session->sftpInit_sftp = NULL; + return rc; }