]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix (real! :-) memory leaks in half_cmp and half_binop.
authorGuido van Rossum <guido@python.org>
Fri, 18 Oct 2002 14:15:33 +0000 (14:15 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 18 Oct 2002 14:15:33 +0000 (14:15 +0000)
Perhaps found by NealN and valgrind.  Will forward port.

Objects/classobject.c

index f698cc323df70711b4b7865a12320f69a724fa71..ff6f11e08940c481f447b17c414b6d8772502998 100644 (file)
@@ -1357,6 +1357,7 @@ half_binop(PyObject *v, PyObject *w, char *opname, binaryfunc thisfunc,
 
        args = Py_BuildValue("(O)", w);
        if (args == NULL) {
+               Py_DECREF(coercefunc);
                return NULL;
        }
        coerced = PyEval_CallObject(coercefunc, args);
@@ -1553,8 +1554,10 @@ half_cmp(PyObject *v, PyObject *w)
        }
 
        args = Py_BuildValue("(O)", w);
-       if (args == NULL)
+       if (args == NULL) {
+               Py_DECREF(cmp_func);
                return -2;
+       }
 
        result = PyEval_CallObject(cmp_func, args);
        Py_DECREF(args);