Fix potential null pointer dereference

This commit is contained in:
alesapin 2019-01-18 21:57:11 +03:00
parent 66bd80703e
commit 33d5f0c8dd
2 changed files with 12 additions and 0 deletions

View File

@ -56,6 +56,12 @@ struct ReadBufferFromHDFS::ReadBufferFromHDFSImpl
} }
fin = hdfsOpenFile(fs, path.c_str(), O_RDONLY, 0, 0, 0); fin = hdfsOpenFile(fs, path.c_str(), O_RDONLY, 0, 0, 0);
if (fin == nullptr)
{
throw Exception("Unable to open HDFS file: " + path + " error: " + std::string(hdfsGetLastError()),
ErrorCodes::NETWORK_ERROR);
}
} }
~ReadBufferFromHDFSImpl() ~ReadBufferFromHDFSImpl()

View File

@ -60,6 +60,12 @@ struct WriteBufferFromHDFS::WriteBufferFromHDFSImpl
} }
fout = hdfsOpenFile(fs, path.c_str(), O_WRONLY, 0, 0, 0); fout = hdfsOpenFile(fs, path.c_str(), O_WRONLY, 0, 0, 0);
if (fout == nullptr)
{
throw Exception("Unable to open HDFS file: " + path + " error: " + std::string(hdfsGetLastError()),
ErrorCodes::NETWORK_ERROR);
}
} }
~WriteBufferFromHDFSImpl() ~WriteBufferFromHDFSImpl()