]> granicus.if.org Git - python/commitdiff
Issue #9530: Fix undefined behaviour due to signed overflow in testcapi_long.h.
authorMark Dickinson <mdickinson@enthought.com>
Sat, 19 Nov 2011 17:58:15 +0000 (17:58 +0000)
committerMark Dickinson <mdickinson@enthought.com>
Sat, 19 Nov 2011 17:58:15 +0000 (17:58 +0000)
Modules/testcapi_long.h

index 5784452edfccc4d3d191b9c6a9619ec3cc4b6911..6bddad7bb5d249e779fa23a44af5f9194091a37c 100644 (file)
@@ -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.