From 5bea912c64a5db1cb301ad146d55bf3e5070c39d Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 5 Feb 2019 16:32:47 -0800 Subject: bpo-35766 follow-up: Add an error check to new_type_comment() If PyUnicode_DecodeUTF8() returns NULL, PyArena_AddPyObject() would crash. Found by @msullivan for https://github.com/python/typed_ast/pull/93. --- Python/ast.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/ast.c b/Python/ast.c index 45578a850f..c47e1accc8 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; -- cgit v1.2.1