Ticket #97 (closed defect)

Opened 8 years ago

Last modified 8 years ago

call sftp_init and sftp_shutdown twice on a session

Reported by: anonymous Owned by: bagder
Priority: normal Milestone:
Component: SFTP Version:
Keywords: Cc: bagder
Blocked By: Blocks:


i call libssh2_sftp_init and libssh2_sftp_shutdown for the first time, and it is ok. then i call libssh2_sftp_init on the same session, but i got an assert error:

sftp.c:566: sftp_init: Assertion `session->sftpInit_sftp == ((void *)0)' failed.

i'm using the lastest 1.1

what's the problem? the code run good on libssh2-1.0

Change History

comment:1 Changed 8 years ago by bagder

Oh. It looks like its even a memory leak in there. How about this as a fix:

--- 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;

comment:2 Changed 8 years ago by bagder

Thanks for your report and help in improving libssh2!

A fix has just been committed to the source code repo, this case is now considered fixed and closed!

Note: See TracTickets for help on using tickets.