diff options
| author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-09-28 13:45:02 +0000 |
|---|---|---|
| committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-09-28 13:45:02 +0000 |
| commit | 6d9f6affb6f42a1962c806f314bdb656f0f61d79 (patch) | |
| tree | d89f18c2fd290e1b16f24d6bd89c1e787597f657 /Parser | |
| parent | be6bdf7b16a7eb7958f34bd5eb65bcee7733ee96 (diff) | |
| download | cpython-6d9f6affb6f42a1962c806f314bdb656f0f61d79.tar.gz | |
http://bugs.python.org/issue6836
Merging revisions 75103,75104 from trunk to py3k
Diffstat (limited to 'Parser')
| -rw-r--r-- | Parser/parsetok.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c index 14703273c9..90a90a7e73 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -240,16 +240,24 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, } } } else if (tok->encoding != NULL) { + /* 'nodes->n_str' uses PyObject_*, while 'tok->encoding' was + * allocated using PyMem_ + */ node* r = PyNode_New(encoding_decl); - if (!r) { + if (r) + r->n_str = PyObject_MALLOC(strlen(tok->encoding)+1); + if (!r || !r->n_str) { err_ret->error = E_NOMEM; + if (r) + PyObject_FREE(r); n = NULL; goto done; } - r->n_str = tok->encoding; + strcpy(r->n_str, tok->encoding); + PyMem_FREE(tok->encoding); + tok->encoding = NULL; r->n_nchildren = 1; r->n_child = n; - tok->encoding = NULL; n = r; } |
