[Python-checkins] cpython: Issue #9530: Fix undefined behaviour due to signed overflow in testcapi_long.h.

mark.dickinson python-checkins at python.org
Sat Nov 19 18:58:46 CET 2011


http://hg.python.org/cpython/rev/71100ef4f7a2
changeset:   73623:71100ef4f7a2
user:        Mark Dickinson <mdickinson at enthought.com>
date:        Sat Nov 19 17:58:15 2011 +0000
summary:
  Issue #9530: Fix undefined behaviour due to signed overflow in testcapi_long.h.

files:
  Modules/testcapi_long.h |  3 +--
  1 files changed, 1 insertions(+), 2 deletions(-)


diff --git a/Modules/testcapi_long.h b/Modules/testcapi_long.h
--- a/Modules/testcapi_long.h
+++ b/Modules/testcapi_long.h
@@ -33,8 +33,7 @@
             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.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list