diff options
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/grammar.c | 4 | ||||
-rw-r--r-- | Parser/parsetok.c | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Parser/grammar.c b/Parser/grammar.c index b0dafe7..9e7c49a 100644 --- a/Parser/grammar.c +++ b/Parser/grammar.c @@ -199,6 +199,10 @@ translabel(grammar *g, label *lb) else name_len = strlen(src); dest = (char *)malloc(name_len + 1); + if (!dest) { + printf("Can't alloc dest '%s'\n", src); + return; + } strncpy(dest, src, name_len); dest[name_len] = '\0'; free(lb->lb_str); diff --git a/Parser/parsetok.c b/Parser/parsetok.c index a27575c..01a3051 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -225,6 +225,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; @@ -232,6 +237,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, n = r; } +done: PyTokenizer_Free(tok); return n; |