From: Tom Tromey Date: Mon, 7 Nov 2016 04:29:12 +0000 (-0700) Subject: Use gdbpy_ref in call_doc_function X-Git-Tag: gdb-8.0-release~971 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1bb44c9f567c75355c1b4417d88cda959e82a3a3;p=thirdparty%2Fbinutils-gdb.git Use gdbpy_ref in call_doc_function This changes call_doc_function to use gdbpy_ref. 2017-01-10 Tom Tromey * python/py-param.c (call_doc_function): Use gdbpy_ref. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 849c3e1c002..a0bdd9cc49f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2017-01-10 Tom Tromey + + * python/py-param.c (call_doc_function): Use gdbpy_ref. + 2017-01-10 Tom Tromey * python/py-linetable.c (build_line_table_tuple_from_pcs) diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c index 7c3223ff963..d9d8baaf350 100644 --- a/gdb/python/py-param.c +++ b/gdb/python/py-param.c @@ -27,6 +27,7 @@ #include "completer.h" #include "language.h" #include "arch-utils.h" +#include "py-ref.h" /* Parameter constants and their values. */ struct parm_constant @@ -329,15 +330,14 @@ static gdb::unique_xmalloc_ptr call_doc_function (PyObject *obj, PyObject *method, PyObject *arg) { gdb::unique_xmalloc_ptr data; - PyObject *result = PyObject_CallMethodObjArgs (obj, method, arg, NULL); + gdbpy_ref result (PyObject_CallMethodObjArgs (obj, method, arg, NULL)); - if (! result) + if (result == NULL) return NULL; - if (gdbpy_is_string (result)) + if (gdbpy_is_string (result.get ())) { - data = python_string_to_host_string (result); - Py_DECREF (result); + data = python_string_to_host_string (result.get ()); if (! data) return NULL; } @@ -345,7 +345,6 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg) { PyErr_SetString (PyExc_RuntimeError, _("Parameter must return a string value.")); - Py_DECREF (result); return NULL; }