mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 11:09:42 +00:00
Add a safety measure for string loading in BGSM
This commit is contained in:
parent
f9f8c1e591
commit
484a360792
1 changed files with 3 additions and 0 deletions
|
@ -41,6 +41,9 @@ namespace Bgsm
|
|||
|
||||
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');
|
||||
mStream->read(str.data(), length);
|
||||
if (mStream->bad())
|
||||
|
|
Loading…
Reference in a new issue