bpo-40263: Fixes an off-by-one error in _winapi_WaitForMultipleObjects_impl (GH-19501)
(cherry picked from commit 92b5dc780db968f6277f42cb06926dddb7475dc6)
Co-authored-by: Ray Donnelly <mingw.android@gmail.com>
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index f341493..bf2498a 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -1722,7 +1722,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);