From 03b3f045425f201001deb0fc632a7d15f9c18cca Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Dec 2001 16:36:39 +0000 Subject: 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.) --- Objects/rangeobject.c | 6 ++++++ 1 file changed, 6 insertions(+) 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 @@ 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; -- cgit v0.12