(svn r22737) -Fix [FS#4717]: some corrupted savegames could crash OpenTTD instead of showing the "savegame corrupted" message

This commit is contained in:
rubidium
2011-08-12 18:36:47 +00:00
parent c8f19a608d
commit 81074e0ca2
3 changed files with 8 additions and 0 deletions

View File

@@ -38,6 +38,8 @@ static void Load_CHTS()
{
Cheat *cht = (Cheat*)&_cheats;
size_t count = SlGetFieldLength() / 2;
/* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
if (count > sizeof(_cheats) / sizeof(Cheat)) SlErrorCorrupt("Too many cheat values");
for (uint i = 0; i < count; i++) {
cht[i].been_used = (SlReadByte() != 0);