summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-09-23 19:25:48 +0000
committerrubidium <rubidium@openttd.org>2011-09-23 19:25:48 +0000
commit1f266ec97735ab7d917f6161cbe14420cd9affd2 (patch)
tree51c196a0824b93a4255e1309ab1d41bd47bb295f
parentf65a1bd84760108390ee0c86b18b6400a05b4887 (diff)
downloadopenttd-1f266ec97735ab7d917f6161cbe14420cd9affd2.tar.xz
(svn r22955) -Fix: guard from reading outside the silly name list
-rw-r--r--src/strings.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index cf2f60348..ae72e2a25 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1409,7 +1409,7 @@ static char *GetSpecialNameString(char *buff, int ind, StringParameters *args, c
{
switch (ind) {
case 1: // not used
- return strecpy(buff, _silly_company_names[args->GetInt32() & 0xFFFF], last);
+ return strecpy(buff, _silly_company_names[min(args->GetInt32() & 0xFFFF, lengthof(_silly_company_names) - 1)], last);
case 2: // used for Foobar & Co company names
return GenAndCoName(buff, args->GetInt32(), last);