summaryrefslogtreecommitdiffstats
path: root/Modules/selectmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-11-01 19:15:23 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-11-01 19:15:23 (GMT)
commit0168d3d9b1f6c236b23afedab3c61254fcb6f072 (patch)
treeba52f148840c8d548d27f867d3426496a1b77532 /Modules/selectmodule.c
parent5ebe65f8cb541b10f07fb6ce2b4283a26c7e1d80 (diff)
parente4ad37e50efadc319d6c1089222f552dfcbf76ee (diff)
downloadcpython-0168d3d9b1f6c236b23afedab3c61254fcb6f072.zip
cpython-0168d3d9b1f6c236b23afedab3c61254fcb6f072.tar.gz
cpython-0168d3d9b1f6c236b23afedab3c61254fcb6f072.tar.bz2
Issue #16230: Fix a crash in select.select() when one the lists changes size while iterated on.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r--Modules/selectmodule.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 7cec49b..9e53773 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -89,7 +89,7 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
{
int max = -1;
int index = 0;
- Py_ssize_t i, len = -1;
+ Py_ssize_t i;
PyObject* fast_seq = NULL;
PyObject* o = NULL;
@@ -100,9 +100,7 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
if (!fast_seq)
return -1;
- len = PySequence_Fast_GET_SIZE(fast_seq);
-
- for (i = 0; i < len; i++) {
+ for (i = 0; i < PySequence_Fast_GET_SIZE(fast_seq); i++) {
SOCKET v;
/* any intervening fileno() calls could decr this refcnt */