]> granicus.if.org Git - python/commitdiff
long_true_divide(): decref its converted arguments. test_long_future.py
authorTim Peters <tim.peters@gmail.com>
Sun, 4 Nov 2001 23:09:40 +0000 (23:09 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 4 Nov 2001 23:09:40 +0000 (23:09 +0000)
run in an infinite loop no longer grows.  Thanks to Neal Norwitz for
determining that test leaked!

Objects/longobject.c

index 5141d533c7edb0343d82a765ef4db48e32ab752a..899c9405bf734fbfca26ad06f2e4bdba62ad54e9 100644 (file)
@@ -1615,12 +1615,15 @@ long_true_divide(PyObject *v, PyObject *w)
 {
        PyLongObject *a, *b;
        double ad, bd;
-       int aexp, bexp;
+       int aexp, bexp, failed;
 
        CONVERT_BINOP(v, w, &a, &b);
        ad = _PyLong_AsScaledDouble((PyObject *)a, &aexp);
        bd = _PyLong_AsScaledDouble((PyObject *)b, &bexp);
-       if ((ad == -1.0 || bd == -1.0) && PyErr_Occurred())
+       failed = (ad == -1.0 || bd == -1.0) && PyErr_Occurred();
+       Py_DECREF(a);
+       Py_DECREF(b);
+       if (failed)
                return NULL;
 
        if (bd == 0.0) {