summaryrefslogtreecommitdiff
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-27 00:33:35 +0200
committerChristian Heimes <christian@cheimes.de>2013-07-27 00:33:35 +0200
commit9096f1e44bfe5c6af229ea32d9df790bbedb4348 (patch)
treeb6aefbf3bad5e9d52af645c62f3591cb9ef86bab /Python/Python-ast.c
parent70d0128cba691093d2cb863c26433429b485efb4 (diff)
parentda7db911620efbe87a73ed0ea5f2b1e01327505e (diff)
downloadcpython-9096f1e44bfe5c6af229ea32d9df790bbedb4348.tar.gz
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
Diffstat (limited to 'Python/Python-ast.c')
-rw-r--r--Python/Python-ast.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 49d19dacd6..afa6d2e135 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -704,9 +704,13 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
{
if (obj == Py_None)
obj = NULL;
- if (obj)
- PyArena_AddPyObject(arena, obj);
- Py_XINCREF(obj);
+ if (obj) {
+ if (PyArena_AddPyObject(arena, obj) < 0) {
+ *out = NULL;
+ return -1;
+ }
+ Py_INCREF(obj);
+ }
*out = obj;
return 0;
}