From: Guido van Rossum Date: Mon, 15 Dec 1997 17:27:35 +0000 (+0000) Subject: For base 10, cast unsigned long to long before testing overflow. X-Git-Tag: v1.5~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=330aafb0c2741aff0f63ce82d1bcca6e0862cf30;p=python For base 10, cast unsigned long to long before testing overflow. This prevents 4294967296 from being an acceptable way to spell zero! --- diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c index 6f8e9bd049..46c52b8be9 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++; }