summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Src/StringUtil.cpp
diff options
context:
space:
mode:
authorhrydgard <hrydgard@gmail.com>2008-09-14 09:12:19 +0000
committerhrydgard <hrydgard@gmail.com>2008-09-14 09:12:19 +0000
commita56fcd4e981802f82b2dfadd125061d49ef8b104 (patch)
tree459b53d2e1ff8c9fcf2deec75635c45333dc58c3 /Source/Core/Common/Src/StringUtil.cpp
parent0ba3948c427c2588d1b1bb143183738da9662bae (diff)
Fixed some valgrind warnings.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@523 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common/Src/StringUtil.cpp')
-rw-r--r--Source/Core/Common/Src/StringUtil.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Source/Core/Common/Src/StringUtil.cpp b/Source/Core/Common/Src/StringUtil.cpp
index 590b20fc4a..638c301f24 100644
--- a/Source/Core/Common/Src/StringUtil.cpp
+++ b/Source/Core/Common/Src/StringUtil.cpp
@@ -165,6 +165,11 @@ void StringFromFormatV(std::string* out, const char* format, va_list args)
delete [] buf;
buf = new char[newSize + 1];
writtenCount = vsnprintf(buf, newSize, format, args);
+ // ARGH! vsnprintf does no longer return -1 on truncation in newer libc!
+ // WORKAROUND! let's fake the old behaviour (even though it's less efficient).
+ // TODO: figure out why the fix causes an invalid read in strlen called from vsnprintf :(
+ if (writtenCount >= (int)newSize)
+ writtenCount = -1;
newSize *= 2;
}