gh-131505: Move len boundary assertions before using len. (#131536)

Move len boundary assertions before using len.
This commit is contained in:
naya451 2025-05-19 18:10:23 +03:00 committed by GitHub
parent 3fa30d9e9c
commit c45e661226
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -607,9 +607,9 @@ _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer)
len = 0;
}
memcpy(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len);
assert(self->pos + len < PY_SSIZE_T_MAX);
assert(len >= 0);
memcpy(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len);
self->pos += len;
return PyLong_FromSsize_t(len);