# HG changeset patch # User rubidium # Date 2013-02-08 20:31:51 # Node ID 61e99ef9e469958e808da6136bfe1f7921221053 # Parent a1985c02030186fb0b09483c62a6f1bdb6e4581f (svn r24980) -Fix: memory leak in corner case of handling encoded strings diff --git a/src/strings.cpp b/src/strings.cpp --- a/src/strings.cpp +++ b/src/strings.cpp @@ -889,11 +889,11 @@ static char *FormatString(char *buff, co 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));