]> granicus.if.org Git - python/commit
Fix for bug 133489: compiler leaks memory
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 23 Feb 2001 17:55:27 +0000 (17:55 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 23 Feb 2001 17:55:27 +0000 (17:55 +0000)
commit74b3bc47df9979e54c1f0c7866730eb499705f0e
tree81c0697e22f1b41bb628669a016d3ad9dd49b203
parent3e13b1e48bdd0550929f55bac11571116cd655ab
Fix for bug 133489: compiler leaks memory

Two different but related problems:

1. PySymtable_Free() must explicitly DECREF(st->st_cur), which should
always point to the global symtable entry.  This entry is setup by the
first enter_scope() call, but there is never a corresponding
exit_scope() call.

Since each entry has a reference to scopes defined within it, the
missing DECREF caused all symtable entries to be leaked.

2. The leak here masked a separate problem with
PySymtableEntry_New().  When the requested entry was found in
st->st_symbols, the entry was returned without doing an INCREF.

And problem c) The ste_children slot was getting two copies of each
child entry, because it was populating the slot on the first and
second passes.  Now only populate on the first pass.
Python/compile.c
Python/symtable.c