]> granicus.if.org Git - python/commitdiff
long_mul(): The PyNumber_Multiply() call can return a long if the
authorGuido van Rossum <guido@python.org>
Tue, 4 Dec 2001 16:36:39 +0000 (16:36 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Dec 2001 16:36:39 +0000 (16:36 +0000)
result would overflow an int.  Check for this.  (SF bug #488482, Armin
Rigo.)

Objects/rangeobject.c

index 24765f4dec77d36ad774b69652ead41962337333..5095e5254bd67b491a41fff1ef80aa2ce6bf9c51 100644 (file)
@@ -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;