mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Merged revisions 86587 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86587 | benjamin.peterson | 2010-11-20 11:24:04 -0600 (Sat, 20 Nov 2010) | 1 line correct logic when pos is after the string #10467 ........
This commit is contained in:
parent
e062ba48b6
commit
5a1ca6e368
3 changed files with 18 additions and 3 deletions
|
@ -391,15 +391,20 @@ static PyObject *
|
|||
bytesio_readinto(bytesio *self, PyObject *buffer)
|
||||
{
|
||||
void *raw_buffer;
|
||||
Py_ssize_t len;
|
||||
Py_ssize_t len, n;
|
||||
|
||||
CHECK_CLOSED(self);
|
||||
|
||||
if (PyObject_AsWriteBuffer(buffer, &raw_buffer, &len) == -1)
|
||||
return NULL;
|
||||
|
||||
if (self->pos + len > self->string_size)
|
||||
len = self->string_size - self->pos;
|
||||
/* adjust invalid sizes */
|
||||
n = self->string_size - self->pos;
|
||||
if (len > n) {
|
||||
len = n;
|
||||
if (len < 0)
|
||||
len = 0;
|
||||
}
|
||||
|
||||
memcpy(raw_buffer, self->buf + self->pos, len);
|
||||
assert(self->pos + len < PY_SSIZE_T_MAX);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue