Commit ac49e5de authored by Harald Sitter's avatar Harald Sitter
Browse files

sftp: guard sftp_close it's not safe to call with nullptrs

BUG: 447527
parent cb52ad98
Pipeline #160979 passed with stage
in 1 minute and 29 seconds
......@@ -1195,7 +1195,9 @@ Result SFTPInternal::truncate(KIO::filesize_t length)
void SFTPInternal::close()
{
sftp_close(mOpenFile);
if (mOpenFile) {
sftp_close(mOpenFile);
}
mOpenFile = nullptr;
}
......@@ -1265,10 +1267,10 @@ Result SFTPInternal::sftpGet(const QUrl &url, KIO::fileoffset_t offset, int fd)
// Open file
file = sftp_open(mSftp, path.constData(), O_RDONLY, 0);
const auto fileFree = qScopeGuard([file] { sftp_close(file); });
if (file == nullptr) {
return Result::fail(KIO::ERR_CANNOT_OPEN_FOR_READING, url.toString());
}
const auto fileFree = qScopeGuard([file] { sftp_close(file); });
if (const Result result = sftpSendMimetype(file, url); !result.success) {
return result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment