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
This commit is contained in:
Vadim Zeitlin
2006-10-28 14:58:56 +00:00
parent e3ff359189
commit bda041e561

View File

@@ -35,6 +35,7 @@
#endif
#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
@@ -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);
}
// ---------------------------------------------------------------------------