]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Free parse tree when deleting parser.
authorGuido van Rossum <guido@python.org>
Sun, 18 Nov 1990 17:38:42 +0000 (17:38 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 18 Nov 1990 17:38:42 +0000 (17:38 +0000)
Parser/parser.c

index e0b3530f511b5b610d46ec5d194c175c2644d9c0..294c534d0ff469244ed2b4138876db96c492c0c6 100644 (file)
@@ -96,8 +96,6 @@ newparser(g, start)
        ps->p_grammar = g;
        ps->p_tree = newnode(start);
        if (ps->p_tree == NULL) {
-               if (ps->p_tree != NULL)
-                       DEL(ps->p_tree); /* XXX freeing a node!?! */
                DEL(ps);
                return NULL;
        }
@@ -110,6 +108,9 @@ void
 delparser(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);
 }