X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83efadb7f370ec190f9f2ad414059fcf0d26b931..4e1ba52e0a6749942692db66e852994113eac1af:/src/common/string.cpp?ds=sidebyside diff --git a/src/common/string.cpp b/src/common/string.cpp index 6ddd68f0c7..764e1ff3b8 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -43,6 +43,10 @@ #include #include +#ifndef __WXMSW__ +#include +#endif + #ifdef __SALFORDC__ #include #endif @@ -312,13 +316,15 @@ bool wxStringBase::AllocBeforeWrite(size_t nLen) pData->nAllocLength = nLen; m_pchData = pData->data(); } - - // now we have enough space, just update the string length - pData->nDataLength = nLen; } wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner + // it doesn't really matter what the string length is as it's going to be + // overwritten later but, for extra safety, set it to 0 for now as we may + // have some junk in m_pchData + GetStringData()->nDataLength = 0; + return true; } @@ -1833,7 +1839,14 @@ int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) // vsnprintf() may return either -1 (traditional Unix behaviour) or the // total number of characters which would have been written if the // buffer were large enough - if ( len >= 0 && len <= size ) + // also, it may return an errno may be something like EILSEQ, + // in which case we need to break out + if ( (len >= 0 && len <= size) + // No EOVERFLOW on Windows nor Palm 6.0 +#if !defined(__WXMSW__) && !defined(__WXPALMOS__) + || errno != EOVERFLOW +#endif + ) { // ok, there was enough space break;