From: Guido van Rossum Date: Tue, 4 Dec 2001 16:36:39 +0000 (+0000) Subject: long_mul(): The PyNumber_Multiply() call can return a long if the X-Git-Tag: v2.2.1c1~563 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=03b3f045425f201001deb0fc632a7d15f9c18cca;p=thirdparty%2FPython%2Fcpython.git 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 24765f4dec77..5095e5254bd6 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;