We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c04ddff commit fc9adb6Copy full SHA for fc9adb6
1 file changed
Objects/longobject.c
@@ -668,10 +668,9 @@ _PyLong_NumBits(PyObject *vv)
668
assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0);
669
if (ndigits > 0) {
670
digit msd = v->ob_digit[ndigits - 1];
671
-
672
- result = (ndigits - 1) * PyLong_SHIFT;
673
- if (result / PyLong_SHIFT != (size_t)(ndigits - 1))
+ if ((size_t)(ndigits - 1) > PY_SIZE_MAX / (size_t)PyLong_SHIFT)
674
goto Overflow;
+ result = (size_t)(ndigits - 1) * (size_t)PyLong_SHIFT;
675
do {
676
++result;
677
if (result == 0)
0 commit comments