summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-12-04 16:36:39 (GMT)
committerGuido van Rossum <guido@python.org>2001-12-04 16:36:39 (GMT)
commit03b3f045425f201001deb0fc632a7d15f9c18cca (patch)
treeb8bbde23f9bede61a9925cde7e9083425a87287e
parentb48b6d073794481765159af6e2f4ebce84a42265 (diff)
downloadcpython-03b3f045425f201001deb0fc632a7d15f9c18cca.zip
cpython-03b3f045425f201001deb0fc632a7d15f9c18cca.tar.gz
cpython-03b3f045425f201001deb0fc632a7d15f9c18cca.tar.bz2
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.)
-rw-r--r--Objects/rangeobject.c6
1 files changed, 6 insertions, 0 deletions
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;