From: Vadim Zeitlin Date: Fri, 19 Mar 2004 22:45:18 +0000 (+0000) Subject: fixed wxSnprintf() for Unicode build X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f8991003ff644d27cce66a21d2d762e11b95a793 fixed wxSnprintf() for Unicode build git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 655a9b58b2..f7649183cc 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -919,19 +919,9 @@ int wxSprintf( wxChar *str, const wxChar *format, ... ) va_list argptr; va_start(argptr, format); - // callers of wxSprintf() deserve what they get - //int ret = vswprintf( str, UINT_MAX, wxFormatConverter(format), argptr ); - - // ... true, but if we are going to implement it, they probably still - // deserve something a little better than absolutely guaranteed silent - // failure. For some (very mysterious) reason, this call fails under glibc - // 2.3.2 if str was allocated on the heap and maxsize is larger than this. - // Even more mysterious is that it does still succeed if str was allocated - // on the stack. This should still be plenty large enough for people who - // want to overflow a buffer. The bug was first noticed in unicode builds - // of tex2rtf, but I'm going to fix that to not use this unsafe function - // instead of wasting time diagnosing this further right now. - int ret = vswprintf( str, INT_MAX / 4, wxFormatConverter(format), argptr ); + // note that wxString::Format() uses wxVsnprintf(), not wxSprintf(), so + // it's safe to implement this one in terms of it + wxStrcpy(str, wxString::Format(format, argptr)); va_end(argptr);