stm32/modusocket: Fix NULL deref when accept() an unbound socket.

pull/1/head
iabdalkader 2019-09-13 19:57:23 +02:00 committed by Damien George
parent f469634c0c
commit 73c94bbbd4
1 changed files with 5 additions and 0 deletions

View File

@ -125,6 +125,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_listen_obj, socket_listen);
STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
mod_network_socket_obj_t *self = MP_OBJ_TO_PTR(self_in);
if (self->nic == MP_OBJ_NULL) {
// not bound
mp_raise_OSError(MP_EINVAL);
}
// create new socket object
// starts with empty NIC so that finaliser doesn't run close() method if accept() fails
mod_network_socket_obj_t *socket2 = m_new_obj_with_finaliser(mod_network_socket_obj_t);