]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed FromAscii() changes to correctly handle embedded NULs
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 28 Jun 2007 19:07:00 +0000 (19:07 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 28 Jun 2007 19:07:00 +0000 (19:07 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47011 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/string.cpp

index 7b9f77b28b47918eed64cac21e89ffcf4e75ef1a..77ace82f763bae7317d677ca3651ca43b5c0532e 100644 (file)
@@ -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;