]> granicus.if.org Git - python/commitdiff
For base 10, cast unsigned long to long before testing overflow.
authorGuido van Rossum <guido@python.org>
Mon, 15 Dec 1997 17:27:35 +0000 (17:27 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 15 Dec 1997 17:27:35 +0000 (17:27 +0000)
This prevents 4294967296 from being an acceptable way to spell zero!

Python/mystrtoul.c

index 6f8e9bd049a349da989b4ac35d5646ae06c10687..46c52b8be96f4fed2d7ff2ac56956144c06bc727 100644 (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++;
     }