]> 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:06:02 +0000 (14:06 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 18 Oct 2002 14:06:02 +0000 (14:06 +0000)
Perhaps found by NealN and valgrind.  Will forward port.

Objects/classobject.c

index 8091f0fbd7ee6978045dcbe7e0882ea1bea9c983..93981daf31b6d49f73bf5fb6cbd520eb1da202e1 100644 (file)
@@ -1315,6 +1315,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);
@@ -1507,8 +1508,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);