From: Tom Tromey Date: Fri, 11 Dec 2020 16:33:36 +0000 (-0700) Subject: Use gdbpy_ref in instantiate_pretty_printer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1345dee2805220742355b331934c2cdedf7669c6;p=binutils-gdb.git Use gdbpy_ref in instantiate_pretty_printer This changes instantiate_pretty_printer to use gdbpy_ref, removing a call to Py_DECREF. gdb/ChangeLog 2020-12-11 Tom Tromey * varobj.c (instantiate_pretty_printer): Use gdbpy_ref. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f61cfda48da..90bfac77470 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2020-12-11 Tom Tromey + + * varobj.c (instantiate_pretty_printer): Use gdbpy_ref. + 2020-12-11 Tom Tromey * varobj.c (varobj_clear_saved_item): Remove. diff --git a/gdb/varobj.c b/gdb/varobj.c index 941c38c1ceb..ba0e1357d3f 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -459,16 +459,11 @@ varobj_delete (struct varobj *var, bool only_children) static PyObject * instantiate_pretty_printer (PyObject *constructor, struct value *value) { - PyObject *val_obj = NULL; - PyObject *printer; - - val_obj = value_to_value_object (value); - if (! val_obj) + gdbpy_ref<> val_obj (value_to_value_object (value)); + if (val_obj == nullptr) return NULL; - printer = PyObject_CallFunctionObjArgs (constructor, val_obj, NULL); - Py_DECREF (val_obj); - return printer; + return PyObject_CallFunctionObjArgs (constructor, val_obj.get (), NULL); } #endif