Commit 9a0d7a76 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-24658: os.read() reuses _PY_READ_MAX (GH-10657)

os_read_impl() now also truncates the size to _PY_READ_MAX
on macOS, to avoid to allocate a larger buffer even if _Py_read() is
limited to _PY_READ_MAX bytes (ex: INT_MAX on macOS).
parent 4d73ae77
......@@ -8410,11 +8410,7 @@ os_read_impl(PyObject *module, int fd, Py_ssize_t length)
return posix_error();
}
#ifdef MS_WINDOWS
/* On Windows, the count parameter of read() is an int */
if (length > INT_MAX)
length = INT_MAX;
#endif
length = Py_MIN(length, _PY_READ_MAX);
buffer = PyBytes_FromStringAndSize((char *)NULL, length);
if (buffer == NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment