mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-22 11:23:27 -04:00
Add a safety measure for string loading in BGSM
This commit is contained in:
parent
f9f8c1e591
commit
484a360792
@ -41,6 +41,9 @@ namespace Bgsm
|
|||||||
|
|
||||||
std::string BGSMStream::getSizedString(size_t length)
|
std::string BGSMStream::getSizedString(size_t length)
|
||||||
{
|
{
|
||||||
|
// Prevent potential memory allocation freezes; strings this long are not expected in BGSM
|
||||||
|
if (length > 1024)
|
||||||
|
throw std::runtime_error("Requested string length is too large: " + std::to_string(length));
|
||||||
std::string str(length, '\0');
|
std::string str(length, '\0');
|
||||||
mStream->read(str.data(), length);
|
mStream->read(str.data(), length);
|
||||||
if (mStream->bad())
|
if (mStream->bad())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user