cpython: 73da4fd7542b (original) (raw)

Mercurial > cpython

changeset 99135:73da4fd7542b 3.4

Issue #25388: Fixed tokenizer crash when processing undecodable source code with a null byte. [#25388]

Serhiy Storchaka storchaka@gmail.com
date Sat, 14 Nov 2015 15:10:35 +0200
parents f13a75544b6f
children e4a69eb34ad7 bddc5491d0fb
files Lib/test/test_compile.py Misc/NEWS Parser/tokenizer.c
diffstat 3 files changed, 19 insertions(+), 8 deletions(-)[+] [-] Lib/test/test_compile.py 10 Misc/NEWS 3 Parser/tokenizer.c 14

line wrap: on

line diff

--- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -504,6 +504,16 @@ if 1: res = script_helper.run_python_until_end(fn)[0] self.assertIn(b"Non-UTF-8", res.err)

+ @support.cpython_only def test_compiler_recursion_limit(self): # Expected limit is sys.getrecursionlimit() * the scaling factor

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Release date: tba Core and Builtins ----------------- +- Issue #25388: Fixed tokenizer crash when processing undecodable source code

--- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -187,7 +187,8 @@ error_ret(struct tok_state tok) / XXX tok->decoding_erred = 1; if (tok->fp != NULL && tok->buf != NULL) /* see PyTokenizer_Free */ PyMem_FREE(tok->buf);

@@ -943,11 +944,6 @@ tok_nextc(struct tok_state *tok) } buflen = PyBytes_GET_SIZE(u); buf = PyBytes_AS_STRING(u);

@@ -989,7 +985,6 @@ tok_nextc(struct tok_state *tok) if (tok->buf != NULL) PyMem_FREE(tok->buf); tok->buf = newtok;

@@ -1012,7 +1007,8 @@ tok_nextc(struct tok_state *tok) } if (decoding_fgets(tok->buf, (int)(tok->end - tok->buf), tok) == NULL) {

@@ -1046,6 +1042,8 @@ tok_nextc(struct tok_state *tok) return EOF; } tok->buf = newbuf;