diff options
author | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-09-28 13:45:02 (GMT) |
---|---|---|
committer | Kristján Valur Jónsson <kristjan@ccpgames.com> | 2009-09-28 13:45:02 (GMT) |
commit | ae4cfb1bb3a6a597d6daec2620d321279c15eab4 (patch) | |
tree | e84dc618e86e4d7c33337e2b67a0b105ce52d35d /Parser | |
parent | 847ec75d3eed49b898ad69a55edaf65f3c8a7a4a (diff) | |
download | cpython-ae4cfb1bb3a6a597d6daec2620d321279c15eab4.zip cpython-ae4cfb1bb3a6a597d6daec2620d321279c15eab4.tar.gz cpython-ae4cfb1bb3a6a597d6daec2620d321279c15eab4.tar.bz2 |
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 1470327..90a90a7 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; } |