From: Václav Slavík Date: Thu, 28 Jun 2007 19:07:00 +0000 (+0000) Subject: fixed FromAscii() changes to correctly handle embedded NULs X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/602a857b25b6b0a07ab26f13815810cafbe05672?ds=inline fixed FromAscii() changes to correctly handle embedded NULs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47011 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/string.cpp b/src/common/string.cpp index 7b9f77b28b..77ace82f76 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -980,19 +980,18 @@ wxString wxString::FromAscii(const char *ascii, size_t len) wxString res; - wxImplStringBuffer buf(res, len); - wxStringCharType *dest = buf; - - for ( ;; ) { - unsigned char c = (unsigned char)*ascii++; - wxASSERT_MSG( c < 0x80, - _T("Non-ASCII value passed to FromAscii().") ); + wxImplStringBuffer buf(res, len); + wxStringCharType *dest = buf; - *dest++ = (wchar_t)c; + for ( ; len > 0; --len ) + { + unsigned char c = (unsigned char)*ascii++; + wxASSERT_MSG( c < 0x80, + _T("Non-ASCII value passed to FromAscii().") ); - if ( c == '\0' ) - break; + *dest++ = (wchar_t)c; + } } return res;