Commit 99f02d43 authored by Guido van Rossum's avatar Guido van Rossum

Free parse tree when deleting parser.

parent f1270274
...@@ -96,8 +96,6 @@ newparser(g, start) ...@@ -96,8 +96,6 @@ newparser(g, start)
ps->p_grammar = g; ps->p_grammar = g;
ps->p_tree = newnode(start); ps->p_tree = newnode(start);
if (ps->p_tree == NULL) { if (ps->p_tree == NULL) {
if (ps->p_tree != NULL)
DEL(ps->p_tree); /* XXX freeing a node!?! */
DEL(ps); DEL(ps);
return NULL; return NULL;
} }
...@@ -110,6 +108,9 @@ void ...@@ -110,6 +108,9 @@ void
delparser(ps) delparser(ps)
parser_state *ps; parser_state *ps;
{ {
/* NB If you want to save the parse tree,
you must set p_tree to NULL before calling delparser! */
freenode(ps->p_tree);
DEL(ps); DEL(ps);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment