Issue #18552: Check return value of PyArena_AddPyObject() in obj2ast_object().

This commit is contained in:
Christian Heimes 2013-07-27 00:33:35 +02:00
commit b7f1b38dea
3 changed files with 17 additions and 6 deletions

View file

@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #18552: Check return value of PyArena_AddPyObject() in
obj2ast_object().
- Issue #18560: Fix potential NULL pointer dereference in sum(). - Issue #18560: Fix potential NULL pointer dereference in sum().
- Issue #18520: Add a new PyStructSequence_InitType2() function, same than - Issue #18520: Add a new PyStructSequence_InitType2() function, same than

View file

@ -862,9 +862,13 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
{ {
if (obj == Py_None) if (obj == Py_None)
obj = NULL; obj = NULL;
if (obj) if (obj) {
PyArena_AddPyObject(arena, obj); if (PyArena_AddPyObject(arena, obj) < 0) {
Py_XINCREF(obj); *out = NULL;
return -1;
}
Py_INCREF(obj);
}
*out = obj; *out = obj;
return 0; return 0;
} }

View file

@ -704,9 +704,13 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
{ {
if (obj == Py_None) if (obj == Py_None)
obj = NULL; obj = NULL;
if (obj) if (obj) {
PyArena_AddPyObject(arena, obj); if (PyArena_AddPyObject(arena, obj) < 0) {
Py_XINCREF(obj); *out = NULL;
return -1;
}
Py_INCREF(obj);
}
*out = obj; *out = obj;
return 0; return 0;
} }