summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2019-02-11 16:10:42 (GMT)
committerGitHub <noreply@github.com>2019-02-11 16:10:42 (GMT)
commit4b250fc1da9c893803cf724a4974450b5e10bd8a (patch)
treee9ba9f9cb68b8271ff85146593dd98493d2661d2 /Python/ast.c
parent537b6caa565ec2fc304ba6f4400cd347ce2af64b (diff)
downloadcpython-4b250fc1da9c893803cf724a4974450b5e10bd8a.zip
cpython-4b250fc1da9c893803cf724a4974450b5e10bd8a.tar.gz
cpython-4b250fc1da9c893803cf724a4974450b5e10bd8a.tar.bz2
bpo-35766 follow-up: Add an error check to new_type_comment() (#11766)
If PyUnicode_DecodeUTF8() returns NULL, PyArena_AddPyObject() would crash. Found by @msullivan for https://github.com/python/typed_ast/pull/93.
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Python/ast.c b/Python/ast.c
index 76588c3..5cef3fd 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -702,6 +702,8 @@ static string
new_type_comment(const char *s, struct compiling *c)
{
PyObject *res = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
+ if (res == NULL)
+ return NULL;
if (PyArena_AddPyObject(c->c_arena, res) < 0) {
Py_DECREF(res);
return NULL;