mirror of https://github.com/python/cpython
long_mul(): The PyNumber_Multiply() call can return a long if the
result would overflow an int. Check for this. (SF bug #488482, Armin Rigo.)
This commit is contained in:
parent
b48b6d0737
commit
03b3f04542
|
@ -38,10 +38,16 @@ long_mul(long i, long j, long *kk)
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!PyInt_Check(c)) {
|
||||||
|
Py_DECREF(c);
|
||||||
|
goto overflow;
|
||||||
|
}
|
||||||
|
|
||||||
*kk = PyInt_AS_LONG(c);
|
*kk = PyInt_AS_LONG(c);
|
||||||
Py_DECREF(c);
|
Py_DECREF(c);
|
||||||
|
|
||||||
if (*kk > INT_MAX) {
|
if (*kk > INT_MAX) {
|
||||||
|
overflow:
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
"integer multiplication");
|
"integer multiplication");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue