Handle terminating NULL correctly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28312 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2004-07-19 20:51:18 +00:00
parent ae53adb467
commit 81bfa5ae22
2 changed files with 10 additions and 2 deletions

View File

@@ -1251,7 +1251,11 @@ double ElapsedTime::Duration(bool reset) {
#if wxUSE_UNICODE #if wxUSE_UNICODE
wxString stc2wx(const char* str, size_t len) wxString stc2wx(const char* str, size_t len)
{ {
if (str[len] == 0) // note: we assume that str is of length len not including the terminating null.
if (!len)
return wxEmptyString;
else if (str[len-1] == 0)
// It's already terminated correctly. // It's already terminated correctly.
return wxString(str, wxConvUTF8, len); return wxString(str, wxConvUTF8, len);

View File

@@ -1251,7 +1251,11 @@ double ElapsedTime::Duration(bool reset) {
#if wxUSE_UNICODE #if wxUSE_UNICODE
wxString stc2wx(const char* str, size_t len) wxString stc2wx(const char* str, size_t len)
{ {
if (str[len] == 0) // note: we assume that str is of length len not including the terminating null.
if (!len)
return wxEmptyString;
else if (str[len-1] == 0)
// It's already terminated correctly. // It's already terminated correctly.
return wxString(str, wxConvUTF8, len); return wxString(str, wxConvUTF8, len);