]> granicus.if.org Git - python/commitdiff
Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().
authorChristian Heimes <christian@cheimes.de>
Fri, 26 Jul 2013 22:33:13 +0000 (00:33 +0200)
committerChristian Heimes <christian@cheimes.de>
Fri, 26 Jul 2013 22:33:13 +0000 (00:33 +0200)
Misc/NEWS
Parser/asdl_c.py
Python/Python-ast.c

index 769b80e73076a6ffb0419ace7120fa2ae558514e..ff6fe06db7b4323a7983cddfe68af217350b7188 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.3.3 release candidate 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 #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
index 25682229cc5c90a3e55cd87b649cbe92a11442dd..e61aae24d124794cc514f58b2d7ac4b4cede7395 100755 (executable)
@@ -834,9 +834,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;
 }
index d78657ce0755b2f89fd37565e3906e6371c50bb9..7bf2c5092d3f31e93147ca2a25f41399fdde302b 100644 (file)
@@ -688,9 +688,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;
 }