From bda041e5616266c47b3e51b773d98cd92c2c1f92 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 28 Oct 2006 14:58:56 +0000 Subject: [PATCH] check for under/overflow in ToLong/ULong/Double() as well git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42573 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/string.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/common/string.cpp b/src/common/string.cpp index c2bab603e2..418fc9f077 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -35,6 +35,7 @@ #endif #include +#include #include #include @@ -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); } // --------------------------------------------------------------------------- -- 2.45.2