From f1f49c3cce5b0635003a6e848907d00575d35140 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Sat, 23 May 2009 22:30:43 +0200
Subject: [PATCH]  - Anonymous bug report #2795816 revealed that
 libssh2_sftp_shutdown() did not    properly free/cleanup the SFTP handle so
 libssh2 leaked memory and caused    an assert() on subsequent
 libssh2_sftp_init() calls on the same session.

---
 NEWS       | 13 +++++++++++++
 src/sftp.c |  5 ++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index b188271..971364d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,16 @@
+* (May 23 2009) Daniel Stenberg:
+
+ - Anonymous bug report #2795816 revealed that libssh2_sftp_shutdown() did not
+   properly free/cleanup the SFTP handle so libssh2 leaked memory and caused
+   an assert() on subsequent libssh2_sftp_init() calls on the same session.
+
+* (May 20 2009) Daniel Stenberg:
+
+  - made libssh2_sftp_write() properly deal with huge/any sized input buffers.
+
+  - fixed libssh2_channel_write_ex() to return the correct return code, and
+    deal with sending off huge buffers better
+
 * (May 7 2009) Daniel Stenberg:
 
   - linked list code. I got a bit tired of the fact that we don't have any
diff --git a/src/sftp.c b/src/sftp.c
index e559069..a9ca378 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -791,7 +791,10 @@ 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);
 
     return rc;