stream_read(): Shrink memory block to actual read size.

This commit is contained in:
Paul Sokolovsky 2014-01-20 19:40:46 +02:00
parent decd597273
commit ff3bdea49d
1 changed files with 1 additions and 0 deletions

View File

@ -30,6 +30,7 @@ static mp_obj_t stream_read(uint n_args, const mp_obj_t *args) {
if (out_sz == -1) {
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_OSError, "[Errno %d]", error));
} else {
buf = m_realloc(buf, sz + 1, out_sz + 1);
buf[out_sz] = 0;
return mp_obj_new_str(qstr_from_str_take(buf, /*out_sz,*/ sz + 1));
}