[Python-Dev] refleak hunting fun!
Neal Norwitz
neal at metaslash.com
Mon Aug 18 10:31:59 EDT 2003
On Mon, Aug 18, 2003 at 02:25:04PM +0100, Michael Hudson wrote:
>
> I did notice that there are more than just leaks here, I'm afraid:
>
> >>> class BadSeq(tuple):
> ... def __getitem__(self, i):
> ... raise IndexError
> ...
> [25508 refs]
> >>> filter(None, BadSeq((1,)))
> Segmentation fault
I found this seg fault too.
The attached patch fixes the problem. I think it's correct.
Neal
--
Index: Python/bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.294
diff -w -u -r2.294 bltinmodule.c
--- Python/bltinmodule.c 14 Aug 2003 20:37:34 -0000 2.294
+++ Python/bltinmodule.c 18 Aug 2003 13:31:23 -0000
@@ -2174,6 +2174,8 @@
if (tuple->ob_type->tp_as_sequence &&
tuple->ob_type->tp_as_sequence->sq_item) {
item = tuple->ob_type->tp_as_sequence->sq_item(tuple, i);
+ if (item == NULL)
+ goto Fail_1;
} else {
PyErr_SetString(PyExc_TypeError, "filter(): unsubscriptable tuple");
goto Fail_1;
More information about the Python-Dev
mailing list