summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-26 22:33:35 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-26 22:33:35 (GMT)
commitb7f1b38deab39cb55781c9ebc22abd273ca21480 (patch)
treea03f333be9c11e300aefff65410ecd9e715c1f41
parentb318990cacb02b6f59f0b529cb3e6014f4b1c9fd (diff)
parent70c94e7896bc46c81e7b9648bde4745ce874f552 (diff)
downloadcpython-b7f1b38deab39cb55781c9ebc22abd273ca21480.zip
cpython-b7f1b38deab39cb55781c9ebc22abd273ca21480.tar.gz
cpython-b7f1b38deab39cb55781c9ebc22abd273ca21480.tar.bz2
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
-rw-r--r--Misc/NEWS3
-rwxr-xr-xParser/asdl_c.py10
-rw-r--r--Python/Python-ast.c10
3 files changed, 17 insertions, 6 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 321ab6e..80bf9fd 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins
-----------------
+- Issue #18552: Check return value of PyArena_AddPyObject() in
+ obj2ast_object().
+
- Issue #18560: Fix potential NULL pointer dereference in sum().
- Issue #18520: Add a new PyStructSequence_InitType2() function, same than
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 7d586b2..f5cd8e4 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -862,9 +862,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;
}
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 49d19da..afa6d2e 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;
}