summaryrefslogtreecommitdiff
path: root/src/saveload/strings_sl.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-08-12 18:36:47 +0000
committerrubidium <rubidium@openttd.org>2011-08-12 18:36:47 +0000
commit81074e0ca2b8c7fa470db5b657998ac614a810de (patch)
tree721f028bcea87ff250e6a8489890a8055dd8dbdc /src/saveload/strings_sl.cpp
parentc8f19a608da349bdb22e286054daa08d049baf84 (diff)
downloadopenttd-81074e0ca2b8c7fa470db5b657998ac614a810de.tar.xz
(svn r22737) -Fix [FS#4717]: some corrupted savegames could crash OpenTTD instead of showing the "savegame corrupted" message
Diffstat (limited to 'src/saveload/strings_sl.cpp')
-rw-r--r--src/saveload/strings_sl.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/saveload/strings_sl.cpp b/src/saveload/strings_sl.cpp
index 6869a1af6..00180978b 100644
--- a/src/saveload/strings_sl.cpp
+++ b/src/saveload/strings_sl.cpp
@@ -126,7 +126,12 @@ static void Load_NAME()
int index;
while ((index = SlIterateArray()) != -1) {
+ if (index >= NUM_OLD_STRINGS) SlErrorCorrupt("Invalid old name index");
+ if (SlGetFieldLength() > (uint)LEN_OLD_STRINGS) SlErrorCorrupt("Invalid old name length");
+
SlArray(&_old_name_array[LEN_OLD_STRINGS * index], SlGetFieldLength(), SLE_UINT8);
+ /* Make sure the old name is null terminated */
+ _old_name_array[LEN_OLD_STRINGS * index + LEN_OLD_STRINGS - 1] = '\0';
}
}