From 81bfa5ae223e2cc27c2b83e51921e31215d384d8 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 19 Jul 2004 20:51:18 +0000 Subject: [PATCH] Handle terminating NULL correctly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28312 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/PlatWX.cpp | 6 +++++- src/stc/PlatWX.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index d1e45d45fb..b20f68fa34 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -1251,7 +1251,11 @@ double ElapsedTime::Duration(bool reset) { #if wxUSE_UNICODE 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. return wxString(str, wxConvUTF8, len); diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index d1e45d45fb..b20f68fa34 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -1251,7 +1251,11 @@ double ElapsedTime::Duration(bool reset) { #if wxUSE_UNICODE 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. return wxString(str, wxConvUTF8, len); -- 2.45.2