diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dc6ef9ab03d..330718af4f8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-01-10 Tom Tromey + + * python/py-inferior.c (gdbpy_inferiors): Use gdbpy_ref. + 2017-01-10 Tom Tromey * python/py-function.c (convert_values_to_python, fnpy_init): Use diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index f5462a4bbe2..995a3df2648 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -477,22 +477,14 @@ build_inferior_list (struct inferior *inf, void *arg) PyObject * gdbpy_inferiors (PyObject *unused, PyObject *unused2) { - PyObject *list, *tuple; - - list = PyList_New (0); - if (!list) + gdbpy_ref list (PyList_New (0)); + if (list == NULL) return NULL; - if (iterate_over_inferiors (build_inferior_list, list)) - { - Py_DECREF (list); - return NULL; - } + if (iterate_over_inferiors (build_inferior_list, list.get ())) + return NULL; - tuple = PyList_AsTuple (list); - Py_DECREF (list); - - return tuple; + return PyList_AsTuple (list.get ()); } /* Membuf and memory manipulation. */