bpo-40263: Fixes an off-by-one error in _winapi_WaitForMultipleObjects_impl (GH-19501)

(cherry picked from commit 92b5dc780d)

Co-authored-by: Ray Donnelly <mingw.android@gmail.com>
This commit is contained in:
Miss Islington (bot) 2021-07-28 14:52:11 -07:00 committed by GitHub
parent 7d77368807
commit 899e37b202
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -1713,7 +1713,7 @@ _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,
nhandles = PySequence_Length(handle_seq);
if (nhandles == -1)
return NULL;
if (nhandles < 0 || nhandles >= MAXIMUM_WAIT_OBJECTS - 1) {
if (nhandles < 0 || nhandles > MAXIMUM_WAIT_OBJECTS - 1) {
PyErr_Format(PyExc_ValueError,
"need at most %zd handles, got a sequence of length %zd",
MAXIMUM_WAIT_OBJECTS - 1, nhandles);