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

This prevents 4294967296 from being an acceptable way to spell zero!
This commit is contained in:
Guido van Rossum 1997-12-15 17:27:35 +00:00
parent 30da0ea124
commit 330aafb0c2
1 changed files with 8 additions and 2 deletions

View File

@ -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++;
}