diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 330718af4f8..e2cf5b9f5ef 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-01-10 Tom Tromey + + * python/py-breakpoint.c (gdbpy_breakpoints): Use gdbpy_ref. + 2017-01-10 Tom Tromey * python/py-inferior.c (gdbpy_inferiors): Use gdbpy_ref. diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index c8847ffe08a..eedb697786c 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -762,28 +762,20 @@ build_bp_list (struct breakpoint *b, void *arg) PyObject * gdbpy_breakpoints (PyObject *self, PyObject *args) { - PyObject *list, *tuple; - if (bppy_live == 0) return PyTuple_New (0); - list = PyList_New (0); - if (!list) + gdbpy_ref list (PyList_New (0)); + if (list == NULL) return NULL; /* If iterate_over_breakpoints returns non NULL it signals an error condition. In that case abandon building the list and return NULL. */ - if (iterate_over_breakpoints (build_bp_list, list) != NULL) - { - Py_DECREF (list); - return NULL; - } + if (iterate_over_breakpoints (build_bp_list, list.get ()) != NULL) + return NULL; - tuple = PyList_AsTuple (list); - Py_DECREF (list); - - return tuple; + return PyList_AsTuple (list.get ()); } /* Call the "stop" method (if implemented) in the breakpoint