summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-12-15 17:27:35 (GMT)
committerGuido van Rossum <guido@python.org>1997-12-15 17:27:35 (GMT)
commit330aafb0c2741aff0f63ce82d1bcca6e0862cf30 (patch)
tree25ba8ec191755e395410c3a4a621ea3d3e9789ad /Python
parent30da0ea1243955e7f2ab1c85f45e2c20ae1f3c56 (diff)
downloadcpython-330aafb0c2741aff0f63ce82d1bcca6e0862cf30.zip
cpython-330aafb0c2741aff0f63ce82d1bcca6e0862cf30.tar.gz
cpython-330aafb0c2741aff0f63ce82d1bcca6e0862cf30.tar.bz2
For base 10, cast unsigned long to long before testing overflow.
This prevents 4294967296 from being an acceptable way to spell zero!
Diffstat (limited to 'Python')
-rw-r--r--Python/mystrtoul.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c
index 6f8e9bd..46c52b8 100644
--- a/Python/mystrtoul.c
+++ b/Python/mystrtoul.c
@@ -128,8 +128,14 @@ int base;
temp = result;
result = result * base + c;
#ifndef MPW
- if ((result - c) / base != temp) /* overflow */
- ovf = 1;
+ if(base == 10) {
+ if(((long)(result - c) / base != temp)) /* overflow */
+ ovf = 1;
+ }
+ else {
+ if ((result - c) / base != temp) /* overflow */
+ ovf = 1;
+ }
#endif
str++;
}