summaryrefslogtreecommitdiffstats
path: root/Parser/grammar.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-04-10 06:42:25 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-04-10 06:42:25 (GMT)
commit2c4e4f98397bcc591ad3a551e1e57cea0e2bd986 (patch)
treef200b67e22e157d409945e29f400e9766eb61beb /Parser/grammar.c
parent65c05b20e97a493b917fa71f10535512c713c662 (diff)
downloadcpython-2c4e4f98397bcc591ad3a551e1e57cea0e2bd986.zip
cpython-2c4e4f98397bcc591ad3a551e1e57cea0e2bd986.tar.gz
cpython-2c4e4f98397bcc591ad3a551e1e57cea0e2bd986.tar.bz2
SF patch #1467512, fix double free with triple quoted string in standard build.
This was the result of inconsistent use of PyMem_* and PyObject_* allocators. By changing to use PyObject_* allocator almost everywhere, this removes the inconsistency.
Diffstat (limited to 'Parser/grammar.c')
-rw-r--r--Parser/grammar.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Parser/grammar.c b/Parser/grammar.c
index d8e3897..880bf84 100644
--- a/Parser/grammar.c
+++ b/Parser/grammar.c
@@ -20,7 +20,7 @@ newgrammar(int start)
{
grammar *g;
- g = PyMem_NEW(grammar, 1);
+ g = PyObject_MALLOC(sizeof(grammar));
if (g == NULL)
Py_FatalError("no mem for new grammar");
g->g_ndfas = 0;
@@ -37,7 +37,7 @@ adddfa(grammar *g, int type, char *name)
{
dfa *d;
- PyMem_RESIZE(g->g_dfa, dfa, g->g_ndfas + 1);
+ g->g_dfa = PyObject_REALLOC(g->g_dfa, sizeof(dfa) * (g->g_ndfas + 1));
if (g->g_dfa == NULL)
Py_FatalError("no mem to resize dfa in adddfa");
d = &g->g_dfa[g->g_ndfas++];
@@ -55,7 +55,8 @@ addstate(dfa *d)
{
state *s;
- PyMem_RESIZE(d->d_state, state, d->d_nstates + 1);
+ d->d_state = PyObject_REALLOC(d->d_state,
+ sizeof(state) * (d->d_nstates + 1));
if (d->d_state == NULL)
Py_FatalError("no mem to resize state in addstate");
s = &d->d_state[d->d_nstates++];
@@ -78,7 +79,7 @@ addarc(dfa *d, int from, int to, int lbl)
assert(0 <= to && to < d->d_nstates);
s = &d->d_state[from];
- PyMem_RESIZE(s->s_arc, arc, s->s_narcs + 1);
+ s->s_arc = PyObject_REALLOC(s->s_arc, sizeof(arc) * (s->s_narcs + 1));
if (s->s_arc == NULL)
Py_FatalError("no mem to resize arc list in addarc");
a = &s->s_arc[s->s_narcs++];
@@ -97,7 +98,8 @@ addlabel(labellist *ll, int type, char *str)
strcmp(ll->ll_label[i].lb_str, str) == 0)
return i;
}
- PyMem_RESIZE(ll->ll_label, label, ll->ll_nlabels + 1);
+ ll->ll_label = PyObject_REALLOC(ll->ll_label,
+ sizeof(label) * (ll->ll_nlabels + 1));
if (ll->ll_label == NULL)
Py_FatalError("no mem to resize labellist in addlabel");
lb = &ll->ll_label[ll->ll_nlabels++];