summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2019-02-05 16:32:47 -0800
committerGuido van Rossum <guido@python.org>2019-02-05 16:34:47 -0800
commit5bea912c64a5db1cb301ad146d55bf3e5070c39d (patch)
tree7dea004b53f87da94dacacc29e4b527ba46d1ed9
parentcd90f6a3692e0f7ef0a13aae651e19a08d1f9b31 (diff)
downloadcpython-git-ast-new-type-comment-null-check.tar.gz
bpo-35766 follow-up: Add an error check to new_type_comment()ast-new-type-comment-null-check
If PyUnicode_DecodeUTF8() returns NULL, PyArena_AddPyObject() would crash. Found by @msullivan for https://github.com/python/typed_ast/pull/93.
-rw-r--r--Python/ast.c2
1 files changed, 2 insertions, 0 deletions
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;