Fixed crash when loading empty shaders
This commit is contained in:
parent
8327870c9f
commit
3c317cab9b
@ -53,9 +53,12 @@ namespace
|
|||||||
{
|
{
|
||||||
file.seekg(0, std::ios_base::end);
|
file.seekg(0, std::ios_base::end);
|
||||||
std::streamsize size = file.tellg();
|
std::streamsize size = file.tellg();
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
file.seekg(0, std::ios_base::beg);
|
file.seekg(0, std::ios_base::beg);
|
||||||
buffer.resize(size);
|
buffer.resize(size);
|
||||||
file.read(&buffer[0], size);
|
file.read(&buffer[0], size);
|
||||||
|
}
|
||||||
buffer.push_back('\0');
|
buffer.push_back('\0');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -68,11 +71,16 @@ namespace
|
|||||||
// Read the contents of a stream into an array of char
|
// Read the contents of a stream into an array of char
|
||||||
bool getStreamContents(sf::InputStream& stream, std::vector<char>& buffer)
|
bool getStreamContents(sf::InputStream& stream, std::vector<char>& buffer)
|
||||||
{
|
{
|
||||||
|
bool success = true;
|
||||||
sf::Int64 size = stream.getSize();
|
sf::Int64 size = stream.getSize();
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
buffer.resize(static_cast<std::size_t>(size));
|
buffer.resize(static_cast<std::size_t>(size));
|
||||||
sf::Int64 read = stream.read(&buffer[0], size);
|
sf::Int64 read = stream.read(&buffer[0], size);
|
||||||
|
success = (read == size);
|
||||||
|
}
|
||||||
buffer.push_back('\0');
|
buffer.push_back('\0');
|
||||||
return read == size;
|
return success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user