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:
parent
30da0ea124
commit
330aafb0c2
|
@ -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++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue