]> granicus.if.org Git - python/commitdiff
Fix PR#66. Solution: add error checking around l_divmod() calls in
authorGuido van Rossum <guido@python.org>
Mon, 11 Oct 1999 22:34:41 +0000 (22:34 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 11 Oct 1999 22:34:41 +0000 (22:34 +0000)
long_pow().

Objects/longobject.c

index 9f605a1470ea59c4993ee6c383e9e93247b27020..0aecf8f8afa3d3a666b6342e43ec899ac6afba34 100644 (file)
@@ -1350,7 +1350,11 @@ long_pow(a, b, c)
                                temp = (PyLongObject *)long_mul(z, a);
                                Py_DECREF(z);
                                if ((PyObject*)c!=Py_None && temp!=NULL) {
-                                       l_divmod(temp, c, &div, &mod);
+                                       if (l_divmod(temp,c,&div,&mod) < 0) {
+                                               Py_DECREF(temp);
+                                               z = NULL;
+                                               goto error;
+                                       }
                                        Py_XDECREF(div);
                                        Py_DECREF(temp);
                                        temp = mod;
@@ -1365,7 +1369,11 @@ long_pow(a, b, c)
                        temp = (PyLongObject *)long_mul(a, a);
                        Py_DECREF(a);
                        if ((PyObject*)c!=Py_None && temp!=NULL) {
-                               l_divmod(temp, c, &div, &mod);
+                               if (l_divmod(temp, c, &div, &mod) < 0) {
+                                       Py_DECREF(temp);
+                                       z = NULL;
+                                       goto error;
+                               }
                                Py_XDECREF(div);
                                Py_DECREF(temp);
                                temp = mod;
@@ -1382,11 +1390,17 @@ long_pow(a, b, c)
        }
        Py_XDECREF(a);
        if ((PyObject*)c!=Py_None && z!=NULL) {
-                       l_divmod(z, c, &div, &mod);
+               if (l_divmod(z, c, &div, &mod) < 0) {
+                       Py_DECREF(z);
+                       z = NULL;
+               }
+               else {
                        Py_XDECREF(div);
                        Py_DECREF(z);
-                       z=mod;
+                       z = mod;
+               }
        }
+  error:
        return (PyObject *)z;
 }