bpo-37412: Fix os.getcwd() for long path on Windows (GH-14424)
* Fix test for integer overflow.
* Add an unit test.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 197607c..b848710 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -3334,7 +3334,7 @@
terminating \0. If the buffer is too small, len includes
the space needed for the terminator. */
if (len >= Py_ARRAY_LENGTH(wbuf)) {
- if (len >= PY_SSIZE_T_MAX / sizeof(wchar_t)) {
+ if (len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) {
wbuf2 = PyMem_RawMalloc(len * sizeof(wchar_t));
}
else {