From cf49f0267b68c33b0b88f550f2f595bf3170c6ce Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Sun, 12 Apr 2020 18:22:21 +0200 Subject: [PATCH] Fix off-by-one-error in _winapi_WaitForMultipleObjects_impl --- .../next/Windows/2020-04-13-15-20-28.bpo-40263.1KKEbu.rst | 3 +++ Modules/_winapi.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Windows/2020-04-13-15-20-28.bpo-40263.1KKEbu.rst diff --git a/Misc/NEWS.d/next/Windows/2020-04-13-15-20-28.bpo-40263.1KKEbu.rst b/Misc/NEWS.d/next/Windows/2020-04-13-15-20-28.bpo-40263.1KKEbu.rst new file mode 100644 index 00000000000000..0c31606d4928c8 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2020-04-13-15-20-28.bpo-40263.1KKEbu.rst @@ -0,0 +1,3 @@ +This is a follow-on bug from https://bugs.python.org/issue26903. Once that +is applied we run into an off-by-one assertion problem. The assert was not +correct. diff --git a/Modules/_winapi.c b/Modules/_winapi.c index 5dc50fbe4d59d1..36fa48c7cd719e 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c @@ -1705,7 +1705,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);