Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
py/objstringio: Fix StringIO reads at or beyond EOF.
Browse files Browse the repository at this point in the history
Existing code failed if seek() went past EOF (which is acceptable when writing).
  • Loading branch information
tomlogic authored and Paul Sokolovsky committed May 15, 2017
1 parent d5713c8 commit 53461de
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions py/objstringio.c
Expand Up @@ -56,6 +56,9 @@ STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
(void)errcode;
mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
check_stringio_is_open(o);
if (o->vstr->len <= o->pos) { // read to EOF, or seeked to EOF or beyond
return 0;
}
mp_uint_t remaining = o->vstr->len - o->pos;
if (size > remaining) {
size = remaining;
Expand Down

0 comments on commit 53461de

Please sign in to comment.