From cda139d1ded6708665b53e4ed32ccc1d2627e1da Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 28 Mar 2019 07:53:00 -0600 Subject: [PATCH] bpo-36459: Fix a possible double PyMem_FREE() due to tokenizer.c's tok_nextc() (12601) Remove the PyMem_FREE() call added in cb90c89. The buffer will be freed when PyTokenizer_Free() is called on the tokenizer state. --- .../Core and Builtins/2019-03-27-22-35-16.bpo-36459.UAvkKp.rst | 1 + Parser/tokenizer.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-03-27-22-35-16.bpo-36459.UAvkKp.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-03-27-22-35-16.bpo-36459.UAvkKp.rst b/Misc/NEWS.d/next/Core and Builtins/2019-03-27-22-35-16.bpo-36459.UAvkKp.rst new file mode 100644 index 00000000000..6c234a6a76d --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-03-27-22-35-16.bpo-36459.UAvkKp.rst @@ -0,0 +1 @@ +Fix a possible double ``PyMem_FREE()`` due to tokenizer.c's ``tok_nextc()``. diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index ad054975689..58dd1cd30b3 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -963,7 +963,6 @@ tok_nextc(struct tok_state *tok) newbuf = (char *)PyMem_REALLOC(newbuf, newsize); if (newbuf == NULL) { - PyMem_FREE(tok->buf); tok->done = E_NOMEM; tok->cur = tok->inp; return EOF;