From: Neal Norwitz Date: Sat, 12 Aug 2006 01:49:12 +0000 (+0000) Subject: Handle NULL nodes while parsing. I'm not entirely sure this is correct. X-Git-Tag: v2.5c1~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6bf1a8fe8be5d9e5458657befc811e8461e769f5;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Parser/parsetok.c b/Parser/parsetok.c index 5fcaf1b36a72..be53e1c5912f 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -229,6 +229,11 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, } } else if (tok->encoding != NULL) { node* r = PyNode_New(encoding_decl); + if (!r) { + err_ret->error = E_NOMEM; + n = NULL; + goto done; + } r->n_str = tok->encoding; r->n_nchildren = 1; r->n_child = n; @@ -236,6 +241,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, n = r; } +done: PyTokenizer_Free(tok); return n;