From 330aafb0c2741aff0f63ce82d1bcca6e0862cf30 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 15 Dec 1997 17:27:35 +0000 Subject: For base 10, cast unsigned long to long before testing overflow. This prevents 4294967296 from being an acceptable way to spell zero! --- Python/mystrtoul.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Python/mystrtoul.c') 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++; } -- cgit v1.2.1