Skip to content

Commit a1504a7

Browse files
committed
Do not update pos if peek_bytes failed
1 parent 1f2b5c5 commit a1504a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Modules/_io/bytesio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,9 @@ static PyObject *
416416
read_bytes(bytesio *self, Py_ssize_t size)
417417
{
418418
PyObject *bytes = peek_bytes(self, size);
419-
self->pos += size;
419+
if (bytes != NULL) {
420+
self->pos += size;
421+
}
420422
return bytes;
421423
}
422424

0 commit comments

Comments
 (0)