From: Phil Muldoon <pmuldoon@redhat.com>
To: gdb-patches@sourceware.org
Subject: [python] [patch] PR python/13310
Date: Thu, 20 Oct 2011 14:28:00 -0000 [thread overview]
Message-ID: <m362jjzqqt.fsf@redhat.com> (raw)
David Malcolm's GCC plug-in found another bug where we lose a reference.
The first case is we do not decrement "result" after a call to
"python_string_to_host_string". That function returns a xstrdup of the
string PyObject contents, and so "result" does not need to be preserved.
The second case is where we type-check the object, and if it is not a
Python string we set an exception without decrementing "result".
OK?
Cheers,
Phil
--
2011-10-20 Phil Muldoon <pmuldoon@redhat.com>
PR python/13310
* python/py-param.c (call_doc_function): Correctly deference on
function exit.
--
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index d68d8fb..fe31cd1 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -331,6 +331,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
if (gdbpy_is_string (result))
{
data = python_string_to_host_string (result);
+ Py_DECREF (result);
if (! data)
return NULL;
}
@@ -338,6 +339,7 @@ call_doc_function (PyObject *obj, PyObject *method, PyObject *arg)
{
PyErr_SetString (PyExc_RuntimeError,
_("Parameter must return a string value."));
+ Py_DECREF (result);
return NULL;
}
next reply other threads:[~2011-10-20 14:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-20 14:28 Phil Muldoon [this message]
2011-10-20 14:47 ` Tom Tromey
2011-10-24 11:52 ` Phil Muldoon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m362jjzqqt.fsf@redhat.com \
--to=pmuldoon@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox