From 8bbce21e90b835ff45e8c0c1779866f525dbd70e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 6 Apr 2000 14:25:00 +0000 Subject: [PATCH] a not-always-correct assert fixed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/string.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/string.cpp b/src/common/string.cpp index 7ab0612f65..a3678f7e9a 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -290,10 +290,12 @@ void wxString::InitWith(const wxChar *psz, size_t nPos, size_t nLength) { Init(); - if ( nLength == wxSTRING_MAXLEN ) - nLength = wxStrlen(psz + nPos); + // if the length is not given, assume the string to be NUL terminated + if ( nLength == wxSTRING_MAXLEN ) { + wxASSERT_MSG( nPos <= wxStrlen(psz), _T("index out of bounds") ); - wxASSERT_MSG( nPos + nLength <= wxStrlen(psz), _T("index out of bounds") ); + nLength = wxStrlen(psz + nPos); + } STATISTICS_ADD(InitialLength, nLength);