Skip to content

Commit

Permalink
add nullpointer check in LWIP::socket_close
Browse files Browse the repository at this point in the history
  • Loading branch information
chrJost committed Jul 5, 2023
1 parent f9c0cd2 commit 67d845b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions connectivity/lwipstack/source/LWIPStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,9 @@ nsapi_error_t LWIP::socket_close(nsapi_socket_t handle)
/* Check if TCP FSM is in ESTABLISHED state.
* Then give extra time for connection close handshaking until TIME_WAIT state.
* The purpose is to prevent eth/wifi driver stop and FIN ACK corrupt.
* This may happend if network interface disconnect follows immediately after socket_close.*/
if (NETCONNTYPE_GROUP(s->conn->type) == NETCONN_TCP && s->conn->pcb.tcp->state == ESTABLISHED) {
* This may happend if network interface disconnect follows immediately after socket_close.
* In case of a TCP RESET flag, the pcb structure is already deleted, therefore check for nullpointer.*/
if (NETCONNTYPE_GROUP(s->conn->type) == NETCONN_TCP && (nullptr == s->conn->pcb.tcp || s->conn->pcb.tcp->state == ESTABLISHED)) {
_event_flag.clear(TCP_CLOSED_FLAG);
netconn_shutdown(s->conn, false, true);
_event_flag.wait_any(TCP_CLOSED_FLAG, TCP_CLOSE_TIMEOUT);
Expand Down

0 comments on commit 67d845b

Please sign in to comment.