summaryrefslogtreecommitdiffstats
path: root/Parser/parsetok.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1990-11-18 17:39:41 (GMT)
committerGuido van Rossum <guido@python.org>1990-11-18 17:39:41 (GMT)
commit840bcf11a84430826f26e3a9ecce356fff536ed2 (patch)
tree6873670bd390595b75243dfaa4c17ad07d0c4e21 /Parser/parsetok.c
parent99f02d43f3d8d771b9e1b4784a72937bffff5647 (diff)
downloadcpython-840bcf11a84430826f26e3a9ecce356fff536ed2.zip
cpython-840bcf11a84430826f26e3a9ecce356fff536ed2.tar.gz
cpython-840bcf11a84430826f26e3a9ecce356fff536ed2.tar.bz2
Set parse tree in parser data structure to NULL when returning
a valid parse tree to caller, so caller must free the tree.
Diffstat (limited to 'Parser/parsetok.c')
-rw-r--r--Parser/parsetok.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index 01877a1..100ca65 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -53,8 +53,10 @@ parsetok(tok, g, start, n_ret)
str[len] = '\0';
ret = addtoken(ps, (int)type, str);
if (ret != E_OK) {
- if (ret == E_DONE)
+ if (ret == E_DONE) {
*n_ret = ps->p_tree;
+ ps->p_tree = NULL;
+ }
else if (tok->lineno <= 1 && tok->done == E_EOF)
ret = E_EOF;
break;
@@ -112,8 +114,7 @@ parsefile(fp, g, start, ps1, ps2, n_ret)
ret = parsetok(tok, g, start, n_ret);
if (ret == E_TOKEN || ret == E_SYNTAX) {
char *p;
- fprintf(stderr, "Parsing error at line %d:\n",
- tok->lineno);
+ fprintf(stderr, "Parsing error at line %d:\n", tok->lineno);
*tok->inp = '\0';
if (tok->inp > tok->buf && tok->inp[-1] == '\n')
tok->inp[-1] = '\0';