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:
Guido van Rossum 2001-12-04 16:36:39 +00:00
parent b48b6d0737
commit 03b3f04542
1 changed files with 6 additions and 0 deletions

View File

@ -38,10 +38,16 @@ long_mul(long i, long j, long *kk)
if (c == NULL)
return 0;
if (!PyInt_Check(c)) {
Py_DECREF(c);
goto overflow;
}
*kk = PyInt_AS_LONG(c);
Py_DECREF(c);
if (*kk > INT_MAX) {
overflow:
PyErr_SetString(PyExc_OverflowError,
"integer multiplication");
return 0;