aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-09-09 14:43:06 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2012-09-09 14:47:31 +0200
commitb0a90fbb0c1085646111f7945b9a5b4af0fd3c78 (patch)
treee9c0e642ac17fdab9241ecea2d94e2a77272406a /src/util.cpp
parenteabc8f2c81712dedd0d93af221e4dbc5b6dede59 (diff)
Add printf-style warnings to strprintf() and OutputDebugStringF()
This finds about ~150 potential problems with format characters on a 64 bit build.
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/util.cpp b/src/util.cpp
index d1270348e0..c9edc782c8 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -274,7 +274,7 @@ inline int OutputDebugStringF(const char* pszFormat, ...)
return ret;
}
-string vstrprintf(const std::string &format, va_list ap)
+string vstrprintf(const char *format, va_list ap)
{
char buffer[50000];
char* p = buffer;
@@ -284,7 +284,7 @@ string vstrprintf(const std::string &format, va_list ap)
{
va_list arg_ptr;
va_copy(arg_ptr, ap);
- ret = _vsnprintf(p, limit, format.c_str(), arg_ptr);
+ ret = _vsnprintf(p, limit, format, arg_ptr);
va_end(arg_ptr);
if (ret >= 0 && ret < limit)
break;
@@ -301,7 +301,7 @@ string vstrprintf(const std::string &format, va_list ap)
return str;
}
-string real_strprintf(const std::string &format, int dummy, ...)
+string real_strprintf(const char *format, int dummy, ...)
{
va_list arg_ptr;
va_start(arg_ptr, dummy);
@@ -310,6 +310,15 @@ string real_strprintf(const std::string &format, int dummy, ...)
return str;
}
+string real_strprintf(const std::string &format, int dummy, ...)
+{
+ va_list arg_ptr;
+ va_start(arg_ptr, dummy);
+ string str = vstrprintf(format.c_str(), arg_ptr);
+ va_end(arg_ptr);
+ return str;
+}
+
bool error(const char *format, ...)
{
va_list arg_ptr;