Skip to content

Commit 4b250fc

Browse files
authored
bpo-35766 follow-up: Add an error check to new_type_comment() (python#11766)
If PyUnicode_DecodeUTF8() returns NULL, PyArena_AddPyObject() would crash. Found by @msullivan for python/typed_ast#93.
1 parent 537b6ca commit 4b250fc

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Python/ast.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,8 @@ static string
702702
new_type_comment(const char *s, struct compiling *c)
703703
{
704704
PyObject *res = PyUnicode_DecodeUTF8(s, strlen(s), NULL);
705+
if (res == NULL)
706+
return NULL;
705707
if (PyArena_AddPyObject(c->c_arena, res) < 0) {
706708
Py_DECREF(res);
707709
return NULL;

0 commit comments

Comments
 (0)