diff options
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d7891fa..0cd6340 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5696,7 +5696,7 @@ posix_write(PyObject *self, PyObject *args) { Py_buffer pbuf; int fd; - Py_ssize_t size; + Py_ssize_t size, len; if (!PyArg_ParseTuple(args, "iy*:write", &fd, &pbuf)) return NULL; @@ -5704,8 +5704,15 @@ posix_write(PyObject *self, PyObject *args) PyBuffer_Release(&pbuf); return posix_error(); } + len = pbuf.len; Py_BEGIN_ALLOW_THREADS - size = write(fd, pbuf.buf, (size_t)pbuf.len); +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (len > INT_MAX) + len = INT_MAX; + size = write(fd, pbuf.buf, (int)len); +#else + size = write(fd, pbuf.buf, (size_t)len); +#endif Py_END_ALLOW_THREADS PyBuffer_Release(&pbuf); if (size < 0) |