Changeset - r25623:d899972faf30
[Not reviewed]
master
0 1 0
rubidium42 - 3 years ago 2021-06-04 16:59:13
rubidium@openttd.org
Fix: [Script] Ensure the saved script strings are properly validated and terminated when being read from the savegame
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/script/script_instance.cpp
Show inline comments
 
@@ -569,8 +569,9 @@ bool ScriptInstance::IsPaused()
 

	
 
		case SQSL_STRING: {
 
			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);
 
			StrMakeValidInPlace(buf, buf + _script_sl_byte);
 
			if (vm != nullptr) sq_pushstring(vm, buf, -1);
 
			return true;
 
		}
0 comments (0 inline, 0 general)