Fixed crashes in Ftp::Upload and Ftp::Download with empty files
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1424 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
d7496629e3
commit
39afb72c4e
@ -380,6 +380,7 @@ Ftp::Response Ftp::Download(const std::string& DistantFile, const std::string& D
|
||||
std::ofstream File((Path + Filename).c_str(), std::ios_base::binary);
|
||||
if (!File)
|
||||
return Response(Response::InvalidFile);
|
||||
if (!FileData.empty())
|
||||
File.write(&FileData[0], static_cast<std::streamsize>(FileData.size()));
|
||||
}
|
||||
}
|
||||
@ -402,6 +403,7 @@ Ftp::Response Ftp::Upload(const std::string& LocalFile, const std::string& DestP
|
||||
std::size_t Length = File.tellg();
|
||||
File.seekg(0, std::ios::beg);
|
||||
std::vector<char> FileData(Length);
|
||||
if (Length > 0)
|
||||
File.read(&FileData[0], static_cast<std::streamsize>(Length));
|
||||
|
||||
// Extract the filename from the file path
|
||||
@ -700,6 +702,7 @@ void Ftp::DataChannel::Receive(std::vector<char>& Data)
|
||||
void Ftp::DataChannel::Send(const std::vector<char>& Data)
|
||||
{
|
||||
// Send data
|
||||
if (!Data.empty())
|
||||
myDataSocket.Send(&Data[0], Data.size());
|
||||
|
||||
// Close the data socket
|
||||
|
Loading…
Reference in New Issue
Block a user