mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 06:42:08 +00:00
- added some safety checks for reading empty lumps into a std::vector.
These can trip the internal safety checks, even though nothing gets read in.
This commit is contained in:
parent
42283f56ab
commit
5a1b858c0e
1 changed files with 12 additions and 5 deletions
|
@ -194,8 +194,11 @@ public:
|
|||
std::vector<uint8_t> Read(size_t len)
|
||||
{
|
||||
std::vector<uint8_t> buffer(len);
|
||||
if (len > 0)
|
||||
{
|
||||
Size length = mReader->Read(&buffer[0], (long)len);
|
||||
buffer.resize((size_t)length);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@ -208,9 +211,13 @@ public:
|
|||
{
|
||||
auto len = GetLength();
|
||||
std::vector<uint8_t> buffer(len + padding);
|
||||
if (len > 0)
|
||||
{
|
||||
Size length = mReader->Read(&buffer[0], (long)len);
|
||||
if (length < len) buffer.clear();
|
||||
else memset(buffer.data() + len, 0, padding);
|
||||
}
|
||||
else buffer[0] = 0;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue