Handle NULL nodes while parsing. I'm not entirely sure this is correct.

There might be something else that needs to be done to setup the error.

Klocwork #295.
This commit is contained in:
Neal Norwitz 2006-08-12 01:49:12 +00:00
parent edb2168079
commit 6bf1a8fe8b
1 changed files with 6 additions and 0 deletions

View File

@ -229,6 +229,11 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
} }
} else if (tok->encoding != NULL) { } else if (tok->encoding != NULL) {
node* r = PyNode_New(encoding_decl); node* r = PyNode_New(encoding_decl);
if (!r) {
err_ret->error = E_NOMEM;
n = NULL;
goto done;
}
r->n_str = tok->encoding; r->n_str = tok->encoding;
r->n_nchildren = 1; r->n_nchildren = 1;
r->n_child = n; r->n_child = n;
@ -236,6 +241,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
n = r; n = r;
} }
done:
PyTokenizer_Free(tok); PyTokenizer_Free(tok);
return n; return n;