stream_read(): Shrink memory block to actual read size.
This commit is contained in:
parent
decd597273
commit
ff3bdea49d
@ -30,6 +30,7 @@ static mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
|
|||||||
if (out_sz == -1) {
|
if (out_sz == -1) {
|
||||||
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_OSError, "[Errno %d]", error));
|
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_OSError, "[Errno %d]", error));
|
||||||
} else {
|
} else {
|
||||||
|
buf = m_realloc(buf, sz + 1, out_sz + 1);
|
||||||
buf[out_sz] = 0;
|
buf[out_sz] = 0;
|
||||||
return mp_obj_new_str(qstr_from_str_take(buf, /*out_sz,*/ sz + 1));
|
return mp_obj_new_str(qstr_from_str_take(buf, /*out_sz,*/ sz + 1));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user