[Python-checkins] cpython (merge 3.3 -> default): Issue #16096: port fix from 3.3

mark.dickinson python-checkins at python.org
Sat Oct 6 19:50:36 CEST 2012


http://hg.python.org/cpython/rev/b728aac3bdb3
changeset:   79533:b728aac3bdb3
parent:      79530:faae99459b43
parent:      79532:906ae6485cb8
user:        Mark Dickinson <mdickinson at enthought.com>
date:        Sat Oct 06 18:50:19 2012 +0100
summary:
  Issue #16096: port fix from 3.3

files:
  Objects/longobject.c |  5 ++---
  1 files changed, 2 insertions(+), 3 deletions(-)


diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -668,10 +668,9 @@
     assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
     if (ndigits > 0) {
         digit msd = v->ob_digit[ndigits - 1];
-
-        result = (ndigits - 1) * PyLong_SHIFT;
-        if (result / PyLong_SHIFT != (size_t)(ndigits - 1))
+        if ((size_t)(ndigits - 1) > PY_SIZE_MAX / (size_t)PyLong_SHIFT)
             goto Overflow;
+        result = (size_t)(ndigits - 1) * (size_t)PyLong_SHIFT;
         do {
             ++result;
             if (result == 0)

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


More information about the Python-checkins mailing list