bpo-40263: Fixes an off-by-one error in _winapi_WaitForMultipleObject… · python/cpython@bccb7b9

Original file line numberDiff line numberDiff line change

@@ -1722,7 +1722,7 @@ _winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,

17221722

nhandles = PySequence_Length(handle_seq);

17231723

if (nhandles == -1)

17241724

return NULL;

1725-

if (nhandles < 0 || nhandles >= MAXIMUM_WAIT_OBJECTS - 1) {

1725+

if (nhandles < 0 || nhandles > MAXIMUM_WAIT_OBJECTS - 1) {

17261726

PyErr_Format(PyExc_ValueError,

17271727

"need at most %zd handles, got a sequence of length %zd",

17281728

MAXIMUM_WAIT_OBJECTS - 1, nhandles);