Commit 50bea12d authored by Guido van Rossum's avatar Guido van Rossum

For base 10, cast unsigned long to long before testing overflow.

This prevents 4294967296 from being an acceptable way to spell zero!
parent 1f98105e
...@@ -128,8 +128,14 @@ int base; ...@@ -128,8 +128,14 @@ int base;
temp = result; temp = result;
result = result * base + c; result = result * base + c;
#ifndef MPW #ifndef MPW
if ((result - c) / base != temp) /* overflow */ if(base == 10) {
ovf = 1; if(((long)(result - c) / base != temp)) /* overflow */
ovf = 1;
}
else {
if ((result - c) / base != temp) /* overflow */
ovf = 1;
}
#endif #endif
str++; str++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment