summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-10-06 17:50:19 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-10-06 17:50:19 (GMT)
commitcf46d62fcb29d7e054ec149a89a8d603252f36b3 (patch)
treef772014859fc2b44185e91347b81fac67972ed24 /Objects
parentff9c54aca28592a3eab0bdba1ddd977b441e1e9f (diff)
parentfc9adb62fbfa8d2f81f7224afea43557a4fff409 (diff)
downloadcpython-cf46d62fcb29d7e054ec149a89a8d603252f36b3.zip
cpython-cf46d62fcb29d7e054ec149a89a8d603252f36b3.tar.gz
cpython-cf46d62fcb29d7e054ec149a89a8d603252f36b3.tar.bz2
Issue #16096: port fix from 3.3
Diffstat (limited to 'Objects')
-rw-r--r--Objects/longobject.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 24cf1a5..78dc27a 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -668,10 +668,9 @@ _PyLong_NumBits(PyObject *vv)
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)