summaryrefslogtreecommitdiffstatshomepage
path: root/unix/modsocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/modsocket.c')
-rw-r--r--unix/modsocket.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/unix/modsocket.c b/unix/modsocket.c
index c4e80d3d52..16039bd813 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -167,8 +167,9 @@ STATIC mp_obj_t socket_recv(uint n_args, const mp_obj_t *args) {
int out_sz = recv(self->fd, buf, sz, flags);
RAISE_ERRNO(out_sz, errno);
- buf = m_realloc(buf, sz, out_sz);
- return MP_OBJ_NEW_QSTR(qstr_from_strn_take(buf, out_sz, out_sz));
+ mp_obj_t ret = MP_OBJ_NEW_QSTR(qstr_from_strn(buf, out_sz));
+ m_del(char, buf, sz);
+ return ret;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_recv_obj, 2, 3, socket_recv);