]> granicus.if.org Git - python/commitdiff
Fix refleak in compiler.
authorGuido van Rossum <guido@python.org>
Wed, 21 Mar 2007 21:26:58 +0000 (21:26 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 21 Mar 2007 21:26:58 +0000 (21:26 +0000)
(A symbol table entry was leaked every time a class was compiled.)

Python/compile.c

index 4c22441026eff9a8545f6435b4c7b19e696f476e..a47c8e647603099846c20d4df433cf82cd5ddb75 100644 (file)
@@ -1519,6 +1519,7 @@ compiler_class(struct compiler *c, stmt_ty s)
        PyCodeObject *co;
        PyObject *str;
        PySTEntryObject *ste;
+       int err;
 
        /* initialize statics */
        if (build_class == NULL) {
@@ -1547,7 +1548,9 @@ compiler_class(struct compiler *c, stmt_ty s)
        if (ste == NULL)
                return 0;
        assert(PyList_Check(ste->ste_varnames));
-       if (PyList_Append(ste->ste_varnames, locals) < 0)
+       err = PyList_Append(ste->ste_varnames, locals);
+       Py_DECREF(ste);
+       if (err < 0)
                return 0;
 
        /* 1. compile the class body into a code object */