- 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:
Christoph Oelckers 2023-08-22 22:59:29 +02:00
parent 42283f56ab
commit 5a1b858c0e

View file

@ -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;
}