Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(15736)

Unified Diff: Python/bltinmodule.c

Issue 14010: deeply nested filter segfaults
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Objects/abstract.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Python/bltinmodule.c Tue Mar 19 13:27:24 2013 +0200
+++ b/Python/bltinmodule.c Tue Mar 19 20:08:58 2013 +0200
@@ -391,9 +391,11 @@
filter_dealloc(filterobject *lz)
{
PyObject_GC_UnTrack(lz);
+ Py_TRASHCAN_SAFE_BEGIN(lz)
Py_XDECREF(lz->func);
Py_XDECREF(lz->it);
Py_TYPE(lz)->tp_free(lz);
+ Py_TRASHCAN_SAFE_END(lz)
}
static int
@@ -414,7 +416,10 @@
iternext = *Py_TYPE(it)->tp_iternext;
for (;;) {
+ if (Py_EnterRecursiveCall(" while iterating"))
+ return NULL;
item = iternext(it);
+ Py_LeaveRecursiveCall();
if (item == NULL)
return NULL;
@@ -1031,9 +1036,11 @@
map_dealloc(mapobject *lz)
{
PyObject_GC_UnTrack(lz);
+ Py_TRASHCAN_SAFE_BEGIN(lz)
Py_XDECREF(lz->iters);
Py_XDECREF(lz->func);
Py_TYPE(lz)->tp_free(lz);
+ Py_TRASHCAN_SAFE_END(lz)
}
static int
@@ -2219,9 +2226,11 @@
zip_dealloc(zipobject *lz)
{
PyObject_GC_UnTrack(lz);
+ Py_TRASHCAN_SAFE_BEGIN(lz)
Py_XDECREF(lz->ittuple);
Py_XDECREF(lz->result);
Py_TYPE(lz)->tp_free(lz);
+ Py_TRASHCAN_SAFE_END(lz)
}
static int
@@ -2244,12 +2253,15 @@
if (tuplesize == 0)
return NULL;
+ if (Py_EnterRecursiveCall(" while iterating"))
+ return NULL;
if (Py_REFCNT(result) == 1) {
Py_INCREF(result);
for (i=0 ; i < tuplesize ; i++) {
it = PyTuple_GET_ITEM(lz->ittuple, i);
item = (*Py_TYPE(it)->tp_iternext)(it);
if (item == NULL) {
+ Py_LeaveRecursiveCall();
Py_DECREF(result);
return NULL;
}
@@ -2259,18 +2271,22 @@
}
} else {
result = PyTuple_New(tuplesize);
- if (result == NULL)
+ if (result == NULL) {
+ Py_LeaveRecursiveCall();
return NULL;
+ }
for (i=0 ; i < tuplesize ; i++) {
it = PyTuple_GET_ITEM(lz->ittuple, i);
item = (*Py_TYPE(it)->tp_iternext)(it);
if (item == NULL) {
+ Py_LeaveRecursiveCall();
Py_DECREF(result);
return NULL;
}
PyTuple_SET_ITEM(result, i, item);
}
}
+ Py_LeaveRecursiveCall();
return result;
}
« no previous file with comments | « Objects/abstract.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+