]> granicus.if.org Git - python/commitdiff
long_pow(): Fix more instances of leaks in error cases.
authorTim Peters <tim.peters@gmail.com>
Mon, 30 Aug 2004 02:58:59 +0000 (02:58 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 30 Aug 2004 02:58:59 +0000 (02:58 +0000)
Bugfix candidate -- although long_pow() is so different now I doubt a
patch would apply to 2.3.

Objects/longobject.c

index 05c42ad47d747632b95292ed4055db062139eec7..0103e5c079eaf98e46fe42a35bb0ee6047e751aa 100644 (file)
@@ -2343,7 +2343,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
                if (c) {
                        PyErr_SetString(PyExc_TypeError, "pow() 2nd argument "
                            "cannot be negative when 3rd argument specified");
-                       return NULL;
+                       goto Error;
                }
                else {
                        /* else return a float.  This works because we know
@@ -2361,7 +2361,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
                if (c->ob_size == 0) {
                        PyErr_SetString(PyExc_ValueError,
                                        "pow() 3rd argument cannot be 0");
-                       goto Done;
+                       goto Error;
                }
 
                /* if modulus < 0:
@@ -2390,7 +2390,7 @@ long_pow(PyObject *v, PyObject *w, PyObject *x)
                   Having the base positive just makes things easier. */
                if (a->ob_size < 0) {
                        if (l_divmod(a, c, NULL, &temp) < 0)
-                               goto Done;
+                               goto Error;
                        Py_DECREF(a);
                        a = temp;
                        temp = NULL;