This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] py-inferior.c, check return value of PyList_Append
- From: Michael Snyder <msnyder at vmware dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>, Phil Muldoon <pmuldoon at redhat dot com>
- Date: Wed, 02 Mar 2011 12:40:22 -0800
- Subject: Re: [RFA] py-inferior.c, check return value of PyList_Append
- References: <4D6E8FFC.2090601@vmware.com> <m3r5ap1d63.fsf@fleche.redhat.com>
Tom Tromey wrote:
"Michael" == Michael Snyder <msnyder@vmware.com> writes:
Michael> Just making this up as I go, here, need a review.
Michael> 2011-03-02 Michael Snyder <msnyder@vmware.com>
Michael> * py-inferior.c (inferior_to_inferior_object): Check return
Should be build_inferior_list, not inferior_to_inferior_object.
This code is kind of bogus. I agree with your change, but then the
caller needs a change as well. It should do something like:
if (iterate_over_inferiors (...))
{
Py_DECREF (list);
return NULL;
}
Tom
Like this?
2011-03-02 Michael Snyder <msnyder@vmware.com>
* python/py-inferior.c (build_inferior_list): Error out if
PyList_Append fails.
(gdbpy_inferiors): Error out if build_inferior_list fails.
Index: python/py-inferior.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-inferior.c,v
retrieving revision 1.5
diff -u -p -u -p -r1.5 py-inferior.c
--- python/py-inferior.c 4 Feb 2011 21:54:16 -0000 1.5
+++ python/py-inferior.c 2 Mar 2011 20:38:01 -0000
@@ -326,7 +326,9 @@ build_inferior_list (struct inferior *in
PyObject *list = arg;
PyObject *inferior = inferior_to_inferior_object (inf);
- PyList_Append (list, inferior);
+ if (PyList_Append (list, inferior))
+ return 1;
+
return 0;
}
@@ -343,7 +345,11 @@ gdbpy_inferiors (PyObject *unused, PyObj
if (!list)
return NULL;
- iterate_over_inferiors (build_inferior_list, list);
+ if (iterate_over_inferiors (build_inferior_list, list))
+ {
+ Py_DECREF (list);
+ return NULL;
+ }
return PyList_AsTuple (list);
}