Fix leak of sftp->ext when sftp_new() fails

Signed-off-by: Kevin Fan <kevinfan@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit b5dc8197f7)
This commit is contained in:
Kevin Fan
2015-04-14 11:40:04 -07:00
committed by Andreas Schneider
parent 584ab49b7b
commit d2a990a68e

View File

@@ -126,6 +126,7 @@ sftp_session sftp_new(ssh_session session){
sftp->session = session;
sftp->channel = ssh_channel_new(session);
if (sftp->channel == NULL) {
sftp_ext_free(sftp->ext);
SAFE_FREE(sftp);
return NULL;
@@ -133,6 +134,7 @@ sftp_session sftp_new(ssh_session session){
if (ssh_channel_open_session(sftp->channel)) {
ssh_channel_free(sftp->channel);
sftp_ext_free(sftp->ext);
SAFE_FREE(sftp);
return NULL;