mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 23:50:25 +00:00
Fix: [Script] Ensure the saved script strings are properly validated and terminated when being read from the savegame
This commit is contained in:
parent
bb8fd00760
commit
2924ac48c5
@ -569,8 +569,9 @@ bool ScriptInstance::IsPaused()
|
|||||||
|
|
||||||
case SQSL_STRING: {
|
case SQSL_STRING: {
|
||||||
SlObject(nullptr, _script_byte);
|
SlObject(nullptr, _script_byte);
|
||||||
static char buf[256];
|
static char buf[std::numeric_limits<decltype(_script_sl_byte)>::max()];
|
||||||
SlArray(buf, _script_sl_byte, SLE_CHAR);
|
SlArray(buf, _script_sl_byte, SLE_CHAR);
|
||||||
|
StrMakeValidInPlace(buf, buf + _script_sl_byte);
|
||||||
if (vm != nullptr) sq_pushstring(vm, buf, -1);
|
if (vm != nullptr) sq_pushstring(vm, buf, -1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user