From ca05143ee0912d6bb212657ee91a424735483bb4 Mon Sep 17 00:00:00 2001 From: Wulian233 <1055917385@qq.com> Date: Tue, 29 Apr 2025 18:17:08 +0800 Subject: [PATCH 1/2] Update posixmodule.c --- Modules/posixmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8d7131b2eacf95..39200f24b4393c 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4189,7 +4189,7 @@ posix_getcwd(int use_bytes) /* If the buffer is large enough, len does not include the terminating \0. If the buffer is too small, len includes the space needed for the terminator. */ - if (len >= Py_ARRAY_LENGTH(wbuf)) { + if ((size_t)len >= Py_ARRAY_LENGTH(wbuf)) { if (len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) { wbuf2 = PyMem_RawMalloc(len * sizeof(wchar_t)); } From 87ab5aa5812242aa0b1f685d137475dd67c2995f Mon Sep 17 00:00:00 2001 From: Wulian233 <1055917385@qq.com> Date: Fri, 2 May 2025 17:09:49 +0800 Subject: [PATCH 2/2] Update posixmodule.c --- Modules/posixmodule.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 39200f24b4393c..9046a2c019a8cd 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -4189,8 +4189,8 @@ posix_getcwd(int use_bytes) /* If the buffer is large enough, len does not include the terminating \0. If the buffer is too small, len includes the space needed for the terminator. */ - if ((size_t)len >= Py_ARRAY_LENGTH(wbuf)) { - if (len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) { + if (len >= Py_ARRAY_LENGTH(wbuf)) { + if ((Py_ssize_t)len <= PY_SSIZE_T_MAX / sizeof(wchar_t)) { wbuf2 = PyMem_RawMalloc(len * sizeof(wchar_t)); } else {