summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-20 19:40:46 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-20 20:37:01 +0200
commitff3bdea49d10ea129fafb2e8be0cdaed172a036b (patch)
tree2469d822e9b1cbeb96b8922b09a193c2be256593
parentdecd597273c39311541bfd45ab71974f90dca9e6 (diff)
downloadmicropython-ff3bdea49d10ea129fafb2e8be0cdaed172a036b.tar.gz
micropython-ff3bdea49d10ea129fafb2e8be0cdaed172a036b.zip
stream_read(): Shrink memory block to actual read size.
-rw-r--r--py/stream.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/py/stream.c b/py/stream.c
index 3a87d0444c..34bbea2e0a 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -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));
}