[Python-checkins] cpython (3.3): Issue #16096: Fix signed overflow in Objects/longobject.c. Thanks Serhiy
mark.dickinson
python-checkins at python.org
Sat Oct 6 19:50:34 CEST 2012
http://hg.python.org/cpython/rev/906ae6485cb8
changeset: 79532:906ae6485cb8
branch: 3.3
parent: 79529:152d85b2da3a
user: Mark Dickinson <mdickinson at enthought.com>
date: Sat Oct 06 18:50:02 2012 +0100
summary:
Issue #16096: Fix signed overflow in Objects/longobject.c. Thanks Serhiy Storchaka.
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