* [RFA] py-inferior.c, check return value of PyList_Append
@ 2011-03-02 18:44 Michael Snyder
2011-03-02 20:27 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2011-03-02 18:44 UTC (permalink / raw)
To: gdb-patches; +Cc: Phil Muldoon
[-- Attachment #1: Type: text/plain, Size: 80 bytes --]
Just making this up as I go, here, need a review.
Should anybody get a DECREF?
[-- Attachment #2: py-inferior.txt --]
[-- Type: text/plain, Size: 708 bytes --]
2011-03-02 Michael Snyder <msnyder@vmware.com>
* py-inferior.c (inferior_to_inferior_object): Check return
value from PyList_Append.
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 18:39:54 -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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] py-inferior.c, check return value of PyList_Append
2011-03-02 18:44 [RFA] py-inferior.c, check return value of PyList_Append Michael Snyder
@ 2011-03-02 20:27 ` Tom Tromey
2011-03-02 20:40 ` Michael Snyder
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2011-03-02 20:27 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches, Phil Muldoon
>>>>> "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
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RFA] py-inferior.c, check return value of PyList_Append
2011-03-02 20:27 ` Tom Tromey
@ 2011-03-02 20:40 ` Michael Snyder
2011-03-02 20:56 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2011-03-02 20:40 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Phil Muldoon
[-- Attachment #1: Type: text/plain, Size: 602 bytes --]
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?
[-- Attachment #2: py-inferior2.txt --]
[-- Type: text/plain, Size: 1070 bytes --]
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);
}
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RFA] py-inferior.c, check return value of PyList_Append
2011-03-02 20:40 ` Michael Snyder
@ 2011-03-02 20:56 ` Tom Tromey
2011-03-02 21:21 ` Michael Snyder
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2011-03-02 20:56 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches, Phil Muldoon
>>>>> "Michael" == Michael Snyder <msnyder@vmware.com> writes:
Michael> Like this?
Michael> 2011-03-02 Michael Snyder <msnyder@vmware.com>
Michael> * python/py-inferior.c (build_inferior_list): Error out if
Michael> PyList_Append fails.
Michael> (gdbpy_inferiors): Error out if build_inferior_list fails.
Perfect, thanks!
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFA] py-inferior.c, check return value of PyList_Append
2011-03-02 20:56 ` Tom Tromey
@ 2011-03-02 21:21 ` Michael Snyder
0 siblings, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2011-03-02 21:21 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches, Phil Muldoon
Tom Tromey wrote:
>>>>>> "Michael" == Michael Snyder <msnyder@vmware.com> writes:
>
> Michael> Like this?
>
> Michael> 2011-03-02 Michael Snyder <msnyder@vmware.com>
> Michael> * python/py-inferior.c (build_inferior_list): Error out if
> Michael> PyList_Append fails.
> Michael> (gdbpy_inferiors): Error out if build_inferior_list fails.
>
> Perfect, thanks!
Thus committed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RFA] py-inferior.c, check return value of PyList_Append
@ 2011-03-02 18:43 Michael Snyder
0 siblings, 0 replies; 6+ messages in thread
From: Michael Snyder @ 2011-03-02 18:43 UTC (permalink / raw)
To: gdb-patches; +Cc: Phil Muldoon
[-- Attachment #1: Type: text/plain, Size: 80 bytes --]
Just making this up as I go, here, need a review.
Should anybody get a DECREF?
[-- Attachment #2: py-inferior.txt --]
[-- Type: text/plain, Size: 708 bytes --]
2011-03-02 Michael Snyder <msnyder@vmware.com>
* py-inferior.c (inferior_to_inferior_object): Check return
value from PyList_Append.
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 18:39:54 -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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-02 21:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-02 18:44 [RFA] py-inferior.c, check return value of PyList_Append Michael Snyder
2011-03-02 20:27 ` Tom Tromey
2011-03-02 20:40 ` Michael Snyder
2011-03-02 20:56 ` Tom Tromey
2011-03-02 21:21 ` Michael Snyder
-- strict thread matches above, loose matches on Subject: below --
2011-03-02 18:43 Michael Snyder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox