summaryrefslogtreecommitdiffstats
path: root/Parser/parsetok.c
diff options
context:
space:
mode:
authorKristján Valur Jónsson <kristjan@ccpgames.com>2009-09-28 13:45:02 (GMT)
committerKristján Valur Jónsson <kristjan@ccpgames.com>2009-09-28 13:45:02 (GMT)
commitae4cfb1bb3a6a597d6daec2620d321279c15eab4 (patch)
treee84dc618e86e4d7c33337e2b67a0b105ce52d35d /Parser/parsetok.c
parent847ec75d3eed49b898ad69a55edaf65f3c8a7a4a (diff)
downloadcpython-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/parsetok.c')
-rw-r--r--Parser/parsetok.c14
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;
}