Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a38362

Browse files
committed
Fix refleak in compiler.
(A symbol table entry was leaked every time a class was compiled.)
1 parent 390d29c commit 3a38362

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Python/compile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,6 +1519,7 @@ compiler_class(struct compiler *c, stmt_ty s)
15191519
PyCodeObject *co;
15201520
PyObject *str;
15211521
PySTEntryObject *ste;
1522+
int err;
15221523

15231524
/* initialize statics */
15241525
if (build_class == NULL) {
@@ -1547,7 +1548,9 @@ compiler_class(struct compiler *c, stmt_ty s)
15471548
if (ste == NULL)
15481549
return 0;
15491550
assert(PyList_Check(ste->ste_varnames));
1550-
if (PyList_Append(ste->ste_varnames, locals) < 0)
1551+
err = PyList_Append(ste->ste_varnames, locals);
1552+
Py_DECREF(ste);
1553+
if (err < 0)
15511554
return 0;
15521555

15531556
/* 1. compile the class body into a code object */

0 commit comments

Comments
 (0)