X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a425518dc40b5fa9b8a171f402b89fb9c5a1e547..2dd9690e88b8d081f49ec63375b210f5e6639a45:/src/common/string.cpp?ds=sidebyside diff --git a/src/common/string.cpp b/src/common/string.cpp index 1cb717510f..418fc9f077 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -35,6 +35,7 @@ #endif #include +#include #include #include @@ -174,7 +175,7 @@ void wxStringBase::InitWith(const wxChar *psz, size_t nPos, size_t nLength) // poor man's iterators are "void *" pointers wxStringBase::wxStringBase(const void *pStart, const void *pEnd) { - if ( pEnd > pStart ) + if ( pEnd >= pStart ) { InitWith((const wxChar *)pStart, 0, (const wxChar *)pEnd - (const wxChar *)pStart); @@ -1684,8 +1685,8 @@ bool wxString::ToLong(long *val, int base) const *val = wxStrtol(start, &end, base); // return true only if scan was stopped by the terminating NUL and if the - // string was not empty to start with - return !*end && (end != start); + // string was not empty to start with and no under/overflow occurred + return !*end && (end != start) && (errno != ERANGE); } bool wxString::ToULong(unsigned long *val, int base) const @@ -1698,8 +1699,8 @@ bool wxString::ToULong(unsigned long *val, int base) const *val = wxStrtoul(start, &end, base); // return true only if scan was stopped by the terminating NUL and if the - // string was not empty to start with - return !*end && (end != start); + // string was not empty to start with and no overflow occurred + return !*end && (end != start) && (errno != ERANGE); } bool wxString::ToDouble(double *val) const @@ -1711,8 +1712,8 @@ bool wxString::ToDouble(double *val) const *val = wxStrtod(start, &end); // return true only if scan was stopped by the terminating NUL and if the - // string was not empty to start with - return !*end && (end != start); + // string was not empty to start with and no under/overflow occurred + return !*end && (end != start) && (errno != ERANGE); } // ---------------------------------------------------------------------------