diff options
Diffstat (limited to 'gdb/python/py-function.c')
-rw-r--r-- | gdb/python/py-function.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c index b254ab7..dbd5649 100644 --- a/gdb/python/py-function.c +++ b/gdb/python/py-function.c @@ -109,7 +109,8 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds) if (! PyArg_ParseTuple (args, "s", &name)) return -1; - Py_INCREF (self); + + gdbpy_ref<> self_ref = gdbpy_ref<>::new_reference (self); if (PyObject_HasAttrString (self, "__doc__")) { @@ -120,17 +121,15 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds) { docstring = python_string_to_host_string (ds_obj.get ()); if (docstring == NULL) - { - Py_DECREF (self); - return -1; - } + return -1; } } } if (! docstring) docstring.reset (xstrdup (_("This function is not documented."))); - add_internal_function (name, docstring.release (), fnpy_call, self); + add_internal_function (name, docstring.release (), fnpy_call, + self_ref.release ()); return 0; } |