If the SSH2 Session resource has already been closed, the libssh2
session has been as well, and the LIBSSH2_SESSION* has been set NULL.
If that is the case, we must not call libssh2_sftp_shutdown().
Note that this patch only resolves the particular shutdown issue, but does not generally address using the SSH2 SFTP resource after the SSH2 Session resource has been closed (i.e. calling any of the ssh2_sftp_*() functions after ssh2_disconnect($ssh) still segfaults). This would have to be handled for every ssh2_sftp_*() function individually. If you like, I can amend this PR respectively, or submit another PR. But maybe there is a more elegant solution I'm missing?
If the SSH2 Session resource has already been closed, the libssh2 session has been as well, and the
LIBSSH2_SESSION*
has been set NULL. If that is the case, we must not calllibssh2_sftp_shutdown()
.Note that this patch only resolves the particular shutdown issue, but does not generally address using the SSH2 SFTP resource after the SSH2 Session resource has been closed (i.e. calling any of the
ssh2_sftp_*()
functions afterssh2_disconnect($ssh)
still segfaults). This would have to be handled for everyssh2_sftp_*()
function individually. If you like, I can amend this PR respectively, or submit another PR. But maybe there is a more elegant solution I'm missing?