diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-01 19:16:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-11-01 19:16:07 (GMT) |
commit | 787fbe9d6b1072ff5a8317f39eaed1a409f263f1 (patch) | |
tree | ea356e874579f382c4e912053683332762738731 /Modules/selectmodule.c | |
parent | 53d36b691241f278fa6173034e6edb10154e62d3 (diff) | |
parent | 0168d3d9b1f6c236b23afedab3c61254fcb6f072 (diff) | |
download | cpython-787fbe9d6b1072ff5a8317f39eaed1a409f263f1.zip cpython-787fbe9d6b1072ff5a8317f39eaed1a409f263f1.tar.gz cpython-787fbe9d6b1072ff5a8317f39eaed1a409f263f1.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.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 9128ea3..c0f56a7 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -84,7 +84,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; @@ -95,9 +95,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 */ |