Commit de42cb8e authored by Huff, Israel's avatar Huff, Israel
Browse files

added more error-checking to sftp file read/write

parent 546cf4d7
......@@ -239,6 +239,7 @@ bool SFTPFile::isOpen() { return (p->file != nullptr); }
// on error, returns < 0 and ssh and sftp session errors are set
int64_t SFTPFile::write(QString str)
{
if (nullptr == p->file) return -1;
std::string stdStr = str.toStdString();
const char* buf = stdStr.c_str();
size_t count = strlen(buf);
......@@ -250,7 +251,7 @@ int64_t SFTPFile::write(QString str)
// success
QString SFTPFile::read(size_t nBytes)
{
if (nBytes == 0) return QString();
if (nullptr == p->file || nBytes == 0) return QString();
char* buf = new char[nBytes + 1];
// initialize buff
memset(buf, 0, nBytes + 1);
......
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