[issue9971] Optimize BufferedReader.readinto

STINNER Victor report at bugs.python.org
Wed May 11 10:51:41 CEST 2011


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

Le mardi 10 mai 2011 à 19:06 +0000, John O'Connor a écrit :
> Victor: AFAIK its not actually downcasting.

On Linux 32 bits, size_t is 32 bits, off_t is 64 bits. If the file size
is 4 GB, the downcast may truncate the size of 0 byte. It would be safer
to use off_t type for the n variable in buffered_readinto(), and maybe
cast to size_t on the call to memcpy. At memcpy, it is safe because the
maximum possible value of n is PY_SSIZE_T (2^31-1 on a 32 bits system),
which fit in a size_t.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9971>
_______________________________________


More information about the Python-bugs-list mailing list