From b96172e2cfbbd047959cb8b2a5b84b0b32388842 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sat, 19 Nov 2011 17:58:15 +0000 Subject: [PATCH] Issue #9530: Fix undefined behaviour due to signed overflow in testcapi_long.h. --- Modules/testcapi_long.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/testcapi_long.h b/Modules/testcapi_long.h index 5784452edfc..6bddad7bb5d 100644 --- a/Modules/testcapi_long.h +++ b/Modules/testcapi_long.h @@ -33,8 +33,7 @@ TESTNAME(PyObject *error(const char*)) unsigned TYPENAME uin, uout; /* For 0, 1, 2 use base; for 3, 4, 5 use -base */ - uin = j < 3 ? base - : (unsigned TYPENAME)(-(TYPENAME)base); + uin = j < 3 ? base : 0U - base; /* For 0 & 3, subtract 1. * For 1 & 4, leave alone.