diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-04-10 06:42:25 +0000 |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-04-10 06:42:25 +0000 |
commit | 2c4e4f98397bcc591ad3a551e1e57cea0e2bd986 (patch) | |
tree | f200b67e22e157d409945e29f400e9766eb61beb /Parser/tokenizer.c | |
parent | 65c05b20e97a493b917fa71f10535512c713c662 (diff) | |
download | cpython-git-2c4e4f98397bcc591ad3a551e1e57cea0e2bd986.tar.gz |
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/tokenizer.c')
-rw-r--r-- | Parser/tokenizer.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 001d31a107..469de27b62 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -105,7 +105,7 @@ char *_PyParser_TokenNames[] = { static struct tok_state * tok_new(void) { - struct tok_state *tok = PyMem_NEW(struct tok_state, 1); + struct tok_state *tok = PyMem_MALLOC(sizeof(struct tok_state)); if (tok == NULL) return NULL; tok->buf = tok->cur = tok->end = tok->inp = tok->start = NULL; @@ -721,7 +721,7 @@ tok_stdin_decode(struct tok_state *tok, char **inp) if (converted == NULL) goto error_nomem; - PyMem_FREE(*inp); + PyObject_FREE(*inp); *inp = converted; if (tok->encoding != NULL) PyObject_FREE(tok->encoding); @@ -781,12 +781,12 @@ tok_nextc(register struct tok_state *tok) if (new == NULL) tok->done = E_INTR; else if (*new == '\0') { - PyMem_FREE(new); + PyObject_FREE(new); tok->done = E_EOF; } #if !defined(PGEN) && defined(Py_USING_UNICODE) else if (tok_stdin_decode(tok, &new) != 0) - PyMem_FREE(new); + PyObject_FREE(new); #endif else if (tok->start != NULL) { size_t start = tok->start - tok->buf; @@ -798,7 +798,7 @@ tok_nextc(register struct tok_state *tok) if (buf == NULL) { PyObject_FREE(tok->buf); tok->buf = NULL; - PyMem_FREE(new); + PyObject_FREE(new); tok->done = E_NOMEM; return EOF; } @@ -806,7 +806,7 @@ tok_nextc(register struct tok_state *tok) tok->cur = tok->buf + oldlen; tok->line_start = tok->cur; strcpy(tok->buf + oldlen, new); - PyMem_FREE(new); + PyObject_FREE(new); tok->inp = tok->buf + newlen; tok->end = tok->inp + 1; tok->start = tok->buf + start; |