From b9b34bc898c65d057432be208be0a99cd8d9143a Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 8 Feb 2013 20:31:51 +0000 Subject: (svn r24980) -Fix: memory leak in corner case of handling encoded strings --- src/strings.cpp | 10 +++++----- 1 file 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)); -- cgit v1.2.3-70-g09d2