From 602a857b25b6b0a07ab26f13815810cafbe05672 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 28 Jun 2007 19:07:00 +0000 Subject: [PATCH] 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 --- src/common/string.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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; -- 2.45.2