summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-02-08 20:31:51 +0000
committerrubidium <rubidium@openttd.org>2013-02-08 20:31:51 +0000
commitb9b34bc898c65d057432be208be0a99cd8d9143a (patch)
treee44563ff5015a6092ad11a6e63181f05513fb4f5
parent078fc803626a71bcd6781d659c116cd37856cba1 (diff)
downloadopenttd-b9b34bc898c65d057432be208be0a99cd8d9143a.tar.xz
(svn r24980) -Fix: memory leak in corner case of handling encoded strings
-rw-r--r--src/strings.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/strings.cpp b/src/strings.cpp
index 1e6a0be99..cfeb93b16 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -889,11 +889,11 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
sub_args.SetParam(i++, (uint64)(size_t)g);
}
}
- /* We error'd out in the while, to error out in themain too */
- if (*str == '\0') break;
-
- str = p;
- buff = GetStringWithArgs(buff, (GAME_TEXT_TAB << TAB_COUNT_OFFSET) + stringid, &sub_args, last, true);
+ /* If we didn't error out, we can actually print the string. */
+ if (*str != '\0') {
+ str = p;
+ buff = GetStringWithArgs(buff, (GAME_TEXT_TAB << TAB_COUNT_OFFSET) + stringid, &sub_args, last, true);
+ }
for (int i = 0; i < 20; i++) {
if (sub_args_need_free[i]) free((void *)sub_args.GetParam(i));