mirror of
https://github.com/python/cpython.git
synced 2025-07-20 09:45:21 +00:00
Fix FileIO.readall() (new_buffersize()) for large files
Truncate the buffer size to PY_SSIZE_T_MAX.
This commit is contained in:
parent
950468e553
commit
c5af7730e3
1 changed files with 5 additions and 1 deletions
|
@ -564,7 +564,11 @@ new_buffersize(fileio *self, size_t currentsize
|
||||||
*/
|
*/
|
||||||
if (end >= SMALLCHUNK && end >= pos && pos >= 0) {
|
if (end >= SMALLCHUNK && end >= pos && pos >= 0) {
|
||||||
/* Add 1 so if the file were to grow we'd notice. */
|
/* Add 1 so if the file were to grow we'd notice. */
|
||||||
return currentsize + end - pos + 1;
|
Py_off_t bufsize = currentsize + end - pos + 1;
|
||||||
|
if (bufsize < PY_SSIZE_T_MAX)
|
||||||
|
return (size_t)bufsize;
|
||||||
|
else
|
||||||
|
return PY_SSIZE_T_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue