Skip to content

Commit 3ef7036

authored andcommitted
Move len boundary assertions before using len. (cherry picked from commit c45e661) Co-authored-by: naya451 <[email protected]>
1 parent c869898 commit 3ef7036

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Modules/_io/bytesio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,9 @@ _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer)
583583
len = 0;
584584
}
585585

586-
memcpy(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len);
587586
assert(self->pos + len < PY_SSIZE_T_MAX);
588587
assert(len >= 0);
588+
memcpy(buffer->buf, PyBytes_AS_STRING(self->buf) + self->pos, len);
589589
self->pos += len;
590590

591591
return PyLong_FromSsize_t(len);

0 commit comments

Comments
 (0)

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant