[Python-checkins] cpython (merge 3.3 -> default): Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().

christian.heimes python-checkins at python.org
Sat Jul 27 00:33:48 CEST 2013


http://hg.python.org/cpython/rev/ad90fc28769a
changeset:   84856:ad90fc28769a
parent:      84853:9d26379db328
parent:      84855:65121aa79ab3
user:        Christian Heimes <christian at cheimes.de>
date:        Sat Jul 27 00:33:35 2013 +0200
summary:
  Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().

files:
  Misc/NEWS           |   3 +++
  Parser/asdl_c.py    |  10 +++++++---
  Python/Python-ast.c |  10 +++++++---
  3 files changed, 17 insertions(+), 6 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 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
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -862,9 +862,13 @@
 {
     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
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -704,9 +704,13 @@
 {
     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;
 }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list