summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-10-01 20:35:46 (GMT)
committerGuido van Rossum <guido@python.org>1998-10-01 20:35:46 (GMT)
commit9d904b9389afafdcebc27788cb4ef84377a8d593 (patch)
tree0b6a639a04728fee7203fa84ba407d74eba0757d /Objects/abstract.c
parent4ab5d85efa1d3f917a59059ca2ae02777bb2945d (diff)
downloadcpython-9d904b9389afafdcebc27788cb4ef84377a8d593.zip
cpython-9d904b9389afafdcebc27788cb4ef84377a8d593.tar.gz
cpython-9d904b9389afafdcebc27788cb4ef84377a8d593.tar.bz2
Believe it or not, Solaris 2.6 strtod() can move the end pointer
*beyond* the null byte at the end of the input string, when the input is inf(inity). Discovered by Greg Ward.
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 123455a..bfc0811 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -131,11 +131,12 @@ float_from_string(v)
PyObject *v;
{
extern double strtod Py_PROTO((const char *, char **));
- char *s, *end;
+ char *s, *last, *end;
double x;
char buffer[256]; /* For errors */
s = PyString_AS_STRING(v);
+ last = s + PyString_GET_SIZE(v);
while (*s && isspace(Py_CHARMASK(*s)))
s++;
if (s[0] == '\0') {
@@ -146,6 +147,10 @@ float_from_string(v)
PyFPE_START_PROTECT("float_from_string", return 0)
x = strtod(s, &end);
PyFPE_END_PROTECT(x)
+ /* Believe it or not, Solaris 2.6 can move end *beyond* the null
+ byte at the end of the string, when the input is inf(inity) */
+ if (end > last)
+ end = last;
while (*end && isspace(Py_CHARMASK(*end)))
end++;
if (*end != '\0') {