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.)
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index 24765f4..5095e52 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -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;