From: Tom Tromey <tromey@redhat.com>
To: Project Archer <archer@sourceware.org>
Subject: [[inferior events] partial cleanup for copy_py_list
Date: Tue, 14 Dec 2010 21:41:00 -0000 [thread overview]
Message-ID: <m3ei9kowv9.fsf@fleche.redhat.com> (raw)
This fixes some issues in copy_py_list, but not all.
The patch changes it to check PyList_Append.
I think it should probably use an iterator to go through the list.
Otherwise it is susceptible to a bug where another thread changes the
list while we are iterating over it.
Still, ok to push in this form?
Tom
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 7c686d3..34e5bf8 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -163,10 +163,11 @@ compute_python_string (struct command_line *l)
}
/* Returns a a copy of the give LIST.
- Creates a new reference which must be handeld by the caller. */
+ Creates a new reference which must be handled by the caller. */
PyObject *
-copy_py_list (PyObject *list){
+copy_py_list (PyObject *list)
+{
int i;
PyObject *new_list = PyList_New (0);
@@ -174,7 +175,11 @@ copy_py_list (PyObject *list){
return NULL;
for (i = 0; i < PyList_Size (list); i++)
- PyList_Append (new_list, PyList_GET_ITEM (list, i));
+ if (PyList_Append (new_list, PyList_GET_ITEM (list, i)) < 0)
+ {
+ Py_DECREF (new_list);
+ return NULL;
+ }
return new_list;
}
next reply other threads:[~2010-12-14 21:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-14 21:41 Tom Tromey [this message]
2010-12-15 15:57 ` sami wagiaalla
2010-12-15 16:42 ` Tom Tromey
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=m3ei9kowv9.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=archer@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).