From: naya451 <41294408+naya451@users.noreply.github.com> Date: Mon, 19 May 2025 15:10:23 +0000 (+0300) Subject: gh-131505: Move len boundary assertions before using len. (#131536) X-Git-Tag: v3.15.0a1~1661 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c45e661226558e997e265cf53ce1419213cc10b7;p=thirdparty%2FPython%2Fcpython.git gh-131505: Move len boundary assertions before using len. (#131536) Move len boundary assertions before using len. --- diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index 4cde5f87032a..61cfec435fe6 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -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);