diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-11 21:00:31 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-11 21:00:31 (GMT) |
commit | c5af7730e34f15d917730c66076125d4e545f11a (patch) | |
tree | 9ec4c70c1b7240708ec19bf37447a85e9194cf40 /Modules | |
parent | 950468e5532e2af6bbda8e953854fe74d45aa9f0 (diff) | |
download | cpython-c5af7730e34f15d917730c66076125d4e545f11a.zip cpython-c5af7730e34f15d917730c66076125d4e545f11a.tar.gz cpython-c5af7730e34f15d917730c66076125d4e545f11a.tar.bz2 |
Fix FileIO.readall() (new_buffersize()) for large files
Truncate the buffer size to PY_SSIZE_T_MAX.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/fileio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index dc59455..ba5e096 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -564,7 +564,11 @@ new_buffersize(fileio *self, size_t currentsize */ if (end >= SMALLCHUNK && end >= pos && pos >= 0) { /* 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 |