added check for nullptr in sshclient
This commit is contained in:
parent
3943314142
commit
115be88e5d
2 changed files with 7 additions and 4 deletions
|
@ -26,7 +26,7 @@ namespace libssh {
|
||||||
// qDebug() << "Failed to initialize ssh";
|
// qDebug() << "Failed to initialize ssh";
|
||||||
// return ErrorCode::InternalError;
|
// return ErrorCode::InternalError;
|
||||||
// }
|
// }
|
||||||
if (m_session != NULL) {
|
if (m_session == nullptr) {
|
||||||
m_session = ssh_new();
|
m_session = ssh_new();
|
||||||
|
|
||||||
if (m_session == NULL) {
|
if (m_session == NULL) {
|
||||||
|
@ -80,6 +80,7 @@ namespace libssh {
|
||||||
ssh_disconnect(m_session);
|
ssh_disconnect(m_session);
|
||||||
}
|
}
|
||||||
ssh_free(m_session);
|
ssh_free(m_session);
|
||||||
|
m_session = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +187,7 @@ namespace libssh {
|
||||||
ssh_channel_close(m_channel);
|
ssh_channel_close(m_channel);
|
||||||
}
|
}
|
||||||
ssh_channel_free(m_channel);
|
ssh_channel_free(m_channel);
|
||||||
|
m_channel = nullptr;
|
||||||
}
|
}
|
||||||
qDebug() << ssh_get_error(m_session);
|
qDebug() << ssh_get_error(m_session);
|
||||||
return fromLibsshErrorCode(ssh_get_error_code(m_session));
|
return fromLibsshErrorCode(ssh_get_error_code(m_session));
|
||||||
|
@ -285,6 +287,7 @@ namespace libssh {
|
||||||
auto errorCode = fromLibsshSftpErrorCode(sftp_get_error(m_sftpSession));
|
auto errorCode = fromLibsshSftpErrorCode(sftp_get_error(m_sftpSession));
|
||||||
if (m_sftpSession != NULL) {
|
if (m_sftpSession != NULL) {
|
||||||
sftp_free(m_sftpSession);
|
sftp_free(m_sftpSession);
|
||||||
|
m_sftpSession = nullptr;
|
||||||
}
|
}
|
||||||
qDebug() << ssh_get_error(m_session);
|
qDebug() << ssh_get_error(m_session);
|
||||||
return errorCode;
|
return errorCode;
|
||||||
|
|
|
@ -42,9 +42,9 @@ namespace libssh {
|
||||||
ErrorCode fromLibsshErrorCode(int errorCode);
|
ErrorCode fromLibsshErrorCode(int errorCode);
|
||||||
ErrorCode fromLibsshSftpErrorCode(int errorCode);
|
ErrorCode fromLibsshSftpErrorCode(int errorCode);
|
||||||
|
|
||||||
ssh_session m_session {};
|
ssh_session m_session = nullptr;
|
||||||
ssh_channel m_channel {};
|
ssh_channel m_channel = nullptr;
|
||||||
sftp_session m_sftpSession {};
|
sftp_session m_sftpSession = nullptr;
|
||||||
signals:
|
signals:
|
||||||
void writeToChannelFinished();
|
void writeToChannelFinished();
|
||||||
void sftpFileCopyFinished();
|
void sftpFileCopyFinished();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue