diff options
Diffstat (limited to 'unix')
-rw-r--r-- | unix/input.c | 2 | ||||
-rw-r--r-- | unix/modffi.c | 2 | ||||
-rw-r--r-- | unix/modsocket.c | 5 |
3 files changed, 5 insertions, 4 deletions
diff --git a/unix/input.c b/unix/input.c index 06190306ab..4d856f2ff8 100644 --- a/unix/input.c +++ b/unix/input.c @@ -77,7 +77,7 @@ STATIC mp_obj_t mp_builtin_input(uint n_args, const mp_obj_t *args) { if (line == NULL) { nlr_raise(mp_obj_new_exception(&mp_type_EOFError)); } - mp_obj_t o = mp_obj_new_str((const byte*)line, strlen(line), false); + mp_obj_t o = mp_obj_new_str(line, strlen(line), false); free(line); return o; } diff --git a/unix/modffi.c b/unix/modffi.c index 4ac9fef5aa..bfc840ceff 100644 --- a/unix/modffi.c +++ b/unix/modffi.c @@ -134,7 +134,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type) switch (type) { case 's': { const char *s = (const char *)val; - return mp_obj_new_str((const byte *)s, strlen(s), false); + return mp_obj_new_str(s, strlen(s), false); } case 'v': return mp_const_none; 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); |