Mercurial > cpython-lru_cache-weakref
diff Objects/rangeobject.c @ 21189:a623f9cf9535 legacy-trunk
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.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 04 Dec 2001 16:36:39 +0000 |
| parents | 0e70df98424e |
| children | 070d392042e3 |
line wrap: on
line diff
--- a/Objects/rangeobject.c Tue Dec 04 16:32:04 2001 +0000 +++ b/Objects/rangeobject.c Tue Dec 04 16:36:39 2001 +0000 @@ -38,10 +38,16 @@ 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;
