summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/StringUtil.cpp
diff options
context:
space:
mode:
authorGlenn Rice <glennricster@gmail.com>2010-11-10 23:23:12 +0000
committerGlenn Rice <glennricster@gmail.com>2010-11-10 23:23:12 +0000
commit072a6988564f297bf4b0f7f5d638ef6f6f04b197 (patch)
tree29958c637e4890b9a8249fffddbddef691665e4e /Source/Core/Common/Src/StringUtil.cpp
parent38d06e76d673a20b3de1854a4dd31f1b94a109f1 (diff)
The change to StringFromFormat was overwriting the last character with the NULL terminating character.
Also update a deprecated function call. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6374 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/StringUtil.cpp')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index 0f3fefec7e..1abb93183f 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -54,13 +54,13 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
std::string StringFromFormat(const char* format, ...)
{
int writtenCount = -1;
- size_t newSize = strlen(format) + 4;
+ size_t newSize = strlen(format) + 5;
char *buf = NULL;
va_list args;
while (writtenCount < 0)
{
delete[] buf;
- buf = new char[newSize + 1];
+ buf = new char[newSize];
va_start(args, format);
writtenCount = vsnprintf(buf, newSize, format, args);
@@ -71,7 +71,7 @@ std::string StringFromFormat(const char* format, ...)
// Instead it returns the size of the string we need.
if (writtenCount > (int)newSize)
{
- newSize = writtenCount;
+ newSize = writtenCount + 1;
writtenCount = -1;
}
#else