https://github.com/python/cpython/commit/ccaf865364692087dc74252dd411f6356a1d43f0
commit: ccaf865364692087dc74252dd411f6356a1d43f0
branch: 3.14
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: gpshead <g...@krypto.org>
date: 2025-05-20T09:57:39Z
summary:

[3.14] gh-131505: Move len boundary assertions before using len. (GH-131536) 
(GH-134239)

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

Move len boundary assertions before using len.
(cherry picked from commit c45e661226558e997e265cf53ce1419213cc10b7)

Co-authored-by: naya451 <41294408+naya...@users.noreply.github.com>

files:
M Modules/_io/bytesio.c

diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index e45a2d1a16dcba..8bc7aeacf294ba 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -583,9 +583,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);

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to