diff options
author | rubidium <rubidium@openttd.org> | 2013-02-08 20:32:56 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-02-08 20:32:56 +0000 |
commit | bb225ae39e93dabda532ee449c18b49de98b00af (patch) | |
tree | 5d522a57adf04d7ad81cbfe8f7d982f89690595f | |
parent | b9b34bc898c65d057432be208be0a99cd8d9143a (diff) | |
download | openttd-bb225ae39e93dabda532ee449c18b49de98b00af.tar.xz |
(svn r24981) -Fix: handle corner case where an encoded string contains too many parameters more gracefully
-rw-r--r-- | src/strings.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/strings.cpp b/src/strings.cpp index cfeb93b16..94de57f6f 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1048,8 +1048,13 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg /* Strings that consume arguments */ StringID str = args->GetInt32(b); if (game_script && GB(str, TAB_COUNT_OFFSET, TAB_COUNT_BITS) != GAME_TEXT_TAB) break; - StringParameters sub_args(*args, b - SCC_STRING1 + 1); - buff = GetStringWithArgs(buff, str, &sub_args, last, next_substr_case_index, game_script); + uint size = b - SCC_STRING1 + 1; + if (game_script && size > args->num_param - args->offset) { + buff = strecat(buff, "(too many parameters)", last); + } else { + StringParameters sub_args(*args, size); + buff = GetStringWithArgs(buff, str, &sub_args, last, next_substr_case_index, game_script); + } next_substr_case_index = 0; break; } |