Kaydet (Commit) fc9adb62 authored tarafından Mark Dickinson's avatar Mark Dickinson

Issue #16096: Fix signed overflow in Objects/longobject.c. Thanks Serhiy Storchaka.

üst c04ddff2
...@@ -668,10 +668,9 @@ _PyLong_NumBits(PyObject *vv) ...@@ -668,10 +668,9 @@ _PyLong_NumBits(PyObject *vv)
assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0); assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
if (ndigits > 0) { if (ndigits > 0) {
digit msd = v->ob_digit[ndigits - 1]; digit msd = v->ob_digit[ndigits - 1];
if ((size_t)(ndigits - 1) > PY_SIZE_MAX / (size_t)PyLong_SHIFT)
result = (ndigits - 1) * PyLong_SHIFT;
if (result / PyLong_SHIFT != (size_t)(ndigits - 1))
goto Overflow; goto Overflow;
result = (size_t)(ndigits - 1) * (size_t)PyLong_SHIFT;
do { do {
++result; ++result;
if (result == 0) if (result == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment