diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2001-12-02 12:21:34 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2001-12-02 12:21:34 (GMT) |
commit | 155aad17be54854bea6cafeb5177b19b4cb72bc6 (patch) | |
tree | 3d5a3092633f5a24631b53a00634797a08245921 /Modules | |
parent | 8b6bd42e08336a5a2280d474d0d4ce9cce3c48cd (diff) | |
download | cpython-155aad17be54854bea6cafeb5177b19b4cb72bc6.zip cpython-155aad17be54854bea6cafeb5177b19b4cb72bc6.tar.gz cpython-155aad17be54854bea6cafeb5177b19b4cb72bc6.tar.bz2 |
Patch #486743: remove bad INCREF, propagate exception in append_objects.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/gcmodule.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index f19782b..7f8d71a 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -701,17 +701,19 @@ static char gc_get_objects__doc__[] = ; /* appending objects in a GC list to a Python list */ -static void +static int append_objects(PyObject *py_list, PyGC_Head *gc_list) { PyGC_Head *gc; for (gc = gc_list->gc.gc_next; gc != gc_list; gc = gc->gc.gc_next) { PyObject *op = FROM_GC(gc); if (op != py_list) { - Py_INCREF(op); - PyList_Append(py_list, op); + if (PyList_Append(py_list, op)) { + return -1; /* exception */ + } } } + return 0; } static PyObject * @@ -722,9 +724,12 @@ gc_get_objects(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, ":get_objects")) /* check no args */ return NULL; result = PyList_New(0); - append_objects(result, &_PyGC_generation0); - append_objects(result, &generation1); - append_objects(result, &generation2); + if (append_objects(result, &_PyGC_generation0) || + append_objects(result, &generation1) || + append_objects(result, &generation2)) { + Py_DECREF(result); + return NULL; + } return result; } |